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
76fa3174
Commit
76fa3174
authored
12 years ago
by
Viktor Kuncak
Committed by
Philippe Suter
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Finding an absolute value term from example-works!
parent
c2680c66
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
testcases/SimpInterpret.scala
+67
-0
67 additions, 0 deletions
testcases/SimpInterpret.scala
with
67 additions
and
0 deletions
testcases/SimpInterpret.scala
0 → 100644
+
67
−
0
View file @
76fa3174
//import scala.collection.immutable.Set
//import leon.Annotations._
import
leon.Utils._
object
Interpret
{
abstract
class
BoolTree
case
class
Eq
(
t1
:
IntTree
,
t2
:
IntTree
)
extends
BoolTree
case
class
And
(
t1
:
BoolTree
,
t2
:
BoolTree
)
extends
BoolTree
case
class
Not
(
t
:
BoolTree
)
extends
BoolTree
abstract
class
IntTree
case
class
Const
(
c
:
Int
)
extends
IntTree
case
class
Var
()
extends
IntTree
case
class
Plus
(
t1
:
IntTree
,
t2
:
IntTree
)
extends
IntTree
case
class
Minus
(
t1
:
IntTree
,
t2
:
IntTree
)
extends
IntTree
case
class
Less
(
t1
:
IntTree
,
t2
:
IntTree
)
extends
BoolTree
case
class
If
(
cond
:
BoolTree
,
t
:
IntTree
,
e
:
IntTree
)
extends
IntTree
def
repOk
(
t
:
IntTree
)
:
Boolean
=
{
true
}
def
beval
(
t
:
BoolTree
,
x0
:
Int
)
:
Boolean
=
{
t
match
{
case
Less
(
t1
,
t2
)
=>
ieval
(
t1
,
x0
)
<
ieval
(
t2
,
x0
)
case
Eq
(
t1
,
t2
)
=>
ieval
(
t1
,
x0
)
==
ieval
(
t2
,
x0
)
case
And
(
t1
,
t2
)
=>
beval
(
t1
,
x0
)
&&
beval
(
t2
,
x0
)
case
Not
(
t1
)
=>
!
beval
(
t1
,
x0
)
}
}
def
ieval
(
t
:
IntTree
,
x0
:
Int
)
:
Int
=
{
t
match
{
case
Const
(
c
)
=>
c
case
Var
()
=>
x0
case
Plus
(
t1
,
t2
)
=>
ieval
(
t1
,
x0
)
+
ieval
(
t2
,
x0
)
case
Minus
(
t1
,
t2
)
=>
ieval
(
t1
,
x0
)
-
ieval
(
t2
,
x0
)
case
If
(
c
,
t1
,
t2
)
=>
if
(
beval
(
c
,
x0
))
ieval
(
t1
,
x0
)
else
ieval
(
t2
,
x0
)
}
}
def
computesPositive
(
t
:
IntTree
)
:
Boolean
=
{
ieval
(
t
,
0
)
>=
0
&&
ieval
(
t
,
1
)
>=
0
&&
ieval
(
t
,-
1
)
>=
0
&&
ieval
(
t
,-
2
)
>=
0
&&
ieval
(
t
,
2
)
>=
0
}
def
identityForPositive
(
t
:
IntTree
)
:
Boolean
=
{
ieval
(
t
,
5
)
==
5
&&
ieval
(
t
,
33
)
==
33
&&
ieval
(
t
,
0
)
==
0
&&
ieval
(
t
,
-
1
)
==
1
&&
ieval
(
t
,
-
2
)
==
2
}
def
treeBad
(
t
:
IntTree
)
:
Boolean
=
{
!(
repOk
(
t
)
&&
computesPositive
(
t
)
&&
identityForPositive
(
t
))
}
holds
def
thereIsGoodTree
()
:
Boolean
=
{
!
treeBad
(
If
(
Less
(
Const
(
0
),
Var
()),
Var
(),
Minus
(
Const
(
0
),
Var
())))
}
holds
def
main
(
args
:
Array
[
String
])
{
thereIsGoodTree
()
}
}
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