Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
sturdy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PLMZ
sturdy
Commits
b3d8cff4
Commit
b3d8cff4
authored
Jan 25, 2019
by
Sebastian Erdweg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more arithmetic simplification tests
parent
4c409525
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
9 deletions
+23
-9
stratego/test/SortSemanticsSpec.hs
stratego/test/SortSemanticsSpec.hs
+23
-9
No files found.
stratego/test/SortSemanticsSpec.hs
View file @
b3d8cff4
...
...
@@ -315,27 +315,41 @@ spec = do
it
"reduce Add(Zero,y)"
$
let
?
ctx
=
Ctx
.
fromList
[(
"Succ"
,[
"Exp"
],
"Exp"
),(
"Zero"
,
[]
,
"Exp"
),(
"Add"
,[
"Exp"
,
"Exp"
],
"Exp"
)]
in
let
exp
=
term
"Exp"
in
let
reduce
AddZero
=
Match
(
Cons
"Add"
[
Cons
"Zero"
[]
,
"y"
])
`
Seq
`
Build
"y"
in
seval
0
(
reduce
AddZero
)
exp
`
shouldBe
`
successOrFail
()
(
termEnv
[(
"y"
,
exp
)],
exp
)
let
reduce
=
Match
(
Cons
"Add"
[
Cons
"Zero"
[]
,
"y"
])
`
Seq
`
Build
"y"
in
seval
0
(
reduce
)
exp
`
shouldBe
`
successOrFail
()
(
termEnv
[(
"y"
,
exp
)],
exp
)
it
"reduce Add(x,Zero)"
$
let
?
ctx
=
Ctx
.
fromList
[(
"Succ"
,[
"Exp"
],
"Exp"
),(
"Zero"
,
[]
,
"Exp"
),(
"Add"
,[
"Exp"
,
"Exp"
],
"Exp"
)]
in
let
exp
=
term
"Exp"
in
let
reduce
AddZero
=
Match
(
Cons
"Add"
[
"x"
,
Cons
"Zero"
[]
])
`
Seq
`
Build
"x"
in
seval
0
(
reduce
AddZero
)
exp
`
shouldBe
`
successOrFail
()
(
termEnv
[(
"x"
,
exp
)],
exp
)
let
reduce
=
Match
(
Cons
"Add"
[
"x"
,
Cons
"Zero"
[]
])
`
Seq
`
Build
"x"
in
seval
0
(
reduce
)
exp
`
shouldBe
`
successOrFail
()
(
termEnv
[(
"x"
,
exp
)],
exp
)
it
"reduce Add(Zero,y) < id + Add(x,Zero)"
$
let
?
ctx
=
Ctx
.
fromList
[(
"Succ"
,[
"Exp"
],
"Exp"
),(
"Zero"
,
[]
,
"Exp"
),(
"Add"
,[
"Exp"
,
"Exp"
],
"Exp"
)]
in
let
exp
=
term
"Exp"
in
let
reduce
AddZero
1
=
Match
(
Cons
"Add"
[
Cons
"Zero"
[]
,
"y"
])
`
Seq
`
Build
"y"
in
let
reduce
AddZero
2
=
Match
(
Cons
"Add"
[
"x"
,
Cons
"Zero"
[]
])
`
Seq
`
Build
"x"
in
seval
0
(
reduce
AddZero1
`
leftChoice
`
reduceAddZero
2
)
exp
`
shouldBe
`
successOrFail
()
(
termEnv'
[(
"x"
,
may
exp
),(
"y"
,
may
exp
)],
exp
)
let
reduce1
=
Match
(
Cons
"Add"
[
Cons
"Zero"
[]
,
"y"
])
`
Seq
`
Build
"y"
in
let
reduce2
=
Match
(
Cons
"Add"
[
"x"
,
Cons
"Zero"
[]
])
`
Seq
`
Build
"x"
in
seval
0
(
reduce
1
`
leftChoice
`
reduce
2
)
exp
`
shouldBe
`
successOrFail
()
(
termEnv'
[(
"x"
,
may
exp
),(
"y"
,
may
exp
)],
exp
)
it
"reduce Add(x,y); !x; ?Zero()"
$
let
?
ctx
=
Ctx
.
fromList
[(
"Succ"
,[
"Exp"
],
"Exp"
),(
"Zero"
,
[]
,
"Exp"
),(
"Add"
,[
"Exp"
,
"Exp"
],
"Exp"
)]
in
let
exp
=
term
"Exp"
in
let
reduceAddZero
=
Match
(
Cons
"Add"
[
"x"
,
"y"
])
`
Seq
`
Build
"x"
`
Seq
`
Match
(
Cons
"Zero"
[]
)
`
Seq
`
Build
"y"
in
seval
0
(
reduceAddZero
)
exp
`
shouldBe
`
successOrFail
()
(
termEnv'
[(
"x"
,
must
exp
),(
"y"
,
must
exp
)],
exp
)
let
reduce
=
Match
(
Cons
"Add"
[
"x"
,
"y"
])
`
Seq
`
Build
"x"
`
Seq
`
Match
(
Cons
"Zero"
[]
)
`
Seq
`
Build
"y"
in
seval
0
(
reduce
)
exp
`
shouldBe
`
successOrFail
()
(
termEnv'
[(
"x"
,
must
exp
),(
"y"
,
must
exp
)],
exp
)
it
"reduce Double(x)"
$
let
?
ctx
=
Ctx
.
fromList
[(
"Succ"
,[
"Exp"
],
"Exp"
),(
"Zero"
,
[]
,
"Exp"
),(
"Add"
,[
"Exp"
,
"Exp"
],
"Exp"
),(
"Double"
,[
"Exp"
],
"Exp"
)]
in
let
exp
=
term
"Exp"
in
let
reduce
=
Match
(
Cons
"Double"
[
"x"
])
`
Seq
`
Build
(
Cons
"Add"
[
"x"
,
"x"
])
in
seval
0
(
reduce
)
exp
`
shouldBe
`
successOrFail
()
(
termEnv
[(
"x"
,
exp
)],
exp
)
it
"reduce Add(Zero,y) <+ Add(x,Zero) <+ Double(x)"
$
let
?
ctx
=
Ctx
.
fromList
[(
"Succ"
,[
"Exp"
],
"Exp"
),(
"Zero"
,
[]
,
"Exp"
),(
"Add"
,[
"Exp"
,
"Exp"
],
"Exp"
)]
in
let
exp
=
term
"Exp"
in
let
reduce1
=
Match
(
Cons
"Add"
[
Cons
"Zero"
[]
,
"y"
])
`
Seq
`
Build
"y"
in
let
reduce2
=
Match
(
Cons
"Add"
[
"x"
,
Cons
"Zero"
[]
])
`
Seq
`
Build
"x"
in
let
reduce3
=
Match
(
Cons
"Double"
[
"x"
])
`
Seq
`
Build
(
Cons
"Add"
[
"x"
,
"x"
])
in
seval
0
(
reduce1
`
leftChoice
`
reduce2
`
leftChoice
`
reduce3
)
exp
`
shouldBe
`
successOrFail
()
(
termEnv'
[(
"x"
,
may
exp
),(
"y"
,
may
exp
)],
exp
)
-- prop "should be sound" $ do
-- i <- choose (0,10)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment