Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
curry-packages
currycheck
Commits
6bebdddd
Commit
6bebdddd
authored
Oct 04, 2018
by
Michael Hanus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adss example for non-equivalence of two non-deterministic insert operations
parent
add5179d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
examples/equivalent_operations/NDInsert.curry
examples/equivalent_operations/NDInsert.curry
+25
-0
No files found.
examples/equivalent_operations/NDInsert.curry
0 → 100644
View file @
6bebdddd
--- Example to show the non-equivalence of two versions of a
--- non-deterministic insert operation.
import Test.Prop
-- Non-deterministic defined by overlapping rules:
ndinsert1 :: a -> [a] -> [a]
ndinsert1 x ys = x : ys
ndinsert1 x (y:ys) = y : ndinsert1 x ys
-- Non-deterministic defined by non-overlapping rules:
ndinsert2 :: a -> [a] -> [a]
ndinsert2 x [] = [x]
ndinsert2 x (y:ys) = x : y : ys ? y : ndinsert2 x ys
-- The equality of both ndinsert operations on ground values always succeeds:
ndinsert_groundequiv x xs = ndinsert1 x xs <~> ndinsert2 x xs
-- Actually, ndinsert1 and ndinsert2 are not equivalent, as can be seen
-- by evaluating `head (ndinsert 1 failed)`.
-- Thus, we check the equivalence with CurryCheck:
-- In PAKCS, the counter example is reported by the 7th test:
ndinsert_equiv = ndinsert1 <=> ndinsert2
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