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
40454b13
Commit
40454b13
authored
14 years ago
by
Octavian-Eugen Ganea
Browse files
Options
Downloads
Patches
Plain Diff
No commit message
No commit message
parent
55e2e943
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
testcases/ExprComp.scala
+41
-12
41 additions, 12 deletions
testcases/ExprComp.scala
with
41 additions
and
12 deletions
testcases/ExprComp.scala
+
41
−
12
View file @
40454b13
...
@@ -68,27 +68,37 @@ object ExprComp {
...
@@ -68,27 +68,37 @@ object ExprComp {
case
class
Ok
(
v
:
ValueStack
)
extends
Outcome
case
class
Ok
(
v
:
ValueStack
)
extends
Outcome
case
class
Fail
(
v
:
ValueStack
,
i
:
Instruction
)
extends
Outcome
case
class
Fail
(
v
:
ValueStack
,
i
:
Instruction
)
extends
Outcome
// Running programs on a given initial stack
// Running programs on a given initial stack
def
run
(
p
:
Program
,
vs
:
ValueStack
)
:
Outcome
=
p
match
{
def
run
(
p
:
Program
,
vs
:
ValueStack
)
:
Outcome
=
p
match
{
case
EProgram
()
=>
Ok
(
vs
)
case
EProgram
()
=>
Ok
(
vs
)
case
NProgram
(
i
,
rest
)
=>
case
NProgram
(
i
,
rest
)
=>
val
oRest
=
run
(
rest
,
vs
)
val
oRest
=
run
(
rest
,
vs
)
oRest
match
{
oRest
match
{
case
Fail
(
_
,
_
)
=>
oRest
case
Fail
(
_
,
_
)
=>
oRest
case
Ok
(
vRest
)
=>
case
Ok
(
vRest
)
=>
i
match
{
i
match
{
case
PushVal
(
v
)
=>
Ok
(
NStack
(
v
,
vRest
))
case
PushVal
(
v
)
=>
Ok
(
NStack
(
v
,
vRest
))
case
ApplyBinOp
(
op
)
=>
vRest
match
{
case
ApplyBinOp
(
op
)
=>
vRest
match
{
case
EStack
()
=>
Fail
(
vRest
,
i
)
case
EStack
()
=>
Fail
(
vRest
,
i
)
case
NStack
(
v1
,
vs1
)
=>
vs1
match
{
case
NStack
(
v1
,
vs1
)
=>
vs1
match
{
case
EStack
()
=>
Fail
(
vRest
,
i
)
case
EStack
()
=>
Fail
(
vRest
,
i
)
case
NStack
(
v2
,
vs2
)
=>
Ok
(
NStack
(
evalOp
(
v1
,
op
,
v2
),
vs2
))
case
NStack
(
v2
,
vs2
)
=>
Ok
(
NStack
(
evalOp
(
v1
,
op
,
v2
),
vs2
))
}
}
}
}
}
}
}
}
}
}
// --- this does not work; do not know why
def
property_trivial
()
:
Boolean
=
{
run
(
EProgram
()
,
EStack
()
)
==
Ok
(
EStack
())
}
holds
def
run0
(
p
:
Program
)
=
run
(
p
,
EStack
())
def
run0
(
p
:
Program
)
=
run
(
p
,
EStack
())
// Compiling expressions to programs
// Compiling expressions to programs
...
@@ -108,6 +118,10 @@ object ExprComp {
...
@@ -108,6 +118,10 @@ object ExprComp {
} holds
} holds
*/
*/
/// --- here it goes bad
def
property0
()
:
Boolean
=
{
def
property0
()
:
Boolean
=
{
val
e
=
Binary
(
Constant
(
Value
(
3
)),
Plus
(),
Constant
(
Value
(
5
)))
val
e
=
Binary
(
Constant
(
Value
(
3
)),
Plus
(),
Constant
(
Value
(
5
)))
val
vs
=
EStack
()
val
vs
=
EStack
()
...
@@ -115,6 +129,21 @@ object ExprComp {
...
@@ -115,6 +129,21 @@ object ExprComp {
run
(
compile
(
e
,
acc
),
vs
)
==
Ok
(
NStack
(
eval
(
e
),
vs
))
run
(
compile
(
e
,
acc
),
vs
)
==
Ok
(
NStack
(
eval
(
e
),
vs
))
}
holds
}
holds
//this induction should work (at least on paper it goes ok)
@induct
def
property_general
(
e
:
Expr
,
prog
:
Program
)
:
Boolean
=
{
val
vs
=
EStack
()
val
result
=
run
(
prog
,
vs
)
result
match
{
case
Ok
(
vv
)
=>
run
(
compile
(
e
,
prog
),
vs
)
==
Ok
(
NStack
(
eval
(
e
),
vv
))
case
_
=>
true
}
}
holds
@induct
@induct
def
property1
(
e
:
Expr
)
:
Boolean
=
{
def
property1
(
e
:
Expr
)
:
Boolean
=
{
val
vs
=
EStack
()
val
vs
=
EStack
()
...
...
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