Equational reasoning consists in manipulating definitions in referentially transparent code as if they were mathematical equations.
Questions tagged [equational-reasoning]
22 questions
1
vote
1 answer
Mapping a strict vs. a lazy function
(head . map f) xs = (f . head) xs
It works for every xs list when f is strict.
Can anyone give me example, why with non-strict f it doesnt work?

beja
- 29
- 2
1
vote
1 answer
Induction on lists - Proving Stronger Property (Haskell)
I'll say right off the bat this is for an assignment, and I'm not looking for an answer - just some direction, since I've been working on it for quite a while now. Given the following tail-recursive sum function:
sumTR [ ] acc = acc
sumTR (x:xs)…

user6764248
- 13
- 2
1
vote
3 answers
How does Haskell evaluate this function defined with partial application?
I'm trying to understand how Haskell evalutes pp1 [1,2,3,4] to get [(1,2),(2,3),(3,4)] here:
1. xnull f [] = []
2. xnull f xs = f xs
3. (/:/) f g x = (f x) (g x)
4. pp1 = zip /:/ xnull tail
I start like this:
a) pp1 [1,2,3,4] = (zip /:/ xnull…

Fof
- 407
- 2
- 8
1
vote
1 answer
How does Haskell evaluate this function which undoes list intercalation?
I'm trying to understand how Haskell evalutes sep [1, 2, 3, 4, 5] to get ([1, 3], [2, 4, 5]) where:
sep [ ] = ([ ], [ ])
sep [x] = ([ ], [x])
sep (x1:x2:xs) = let (is, ps) = sep xs in (x1:is, x2:ps)
I start like this:
sep [1, 2, 3, 4, 5] = let (is,…

Fof
- 407
- 2
- 8
1
vote
0 answers
acl2 equational reasoning, proving equality
I'm trying to prove the following function true and am having trouble figuring it out, even though it seems so obvious!
(implies (and (listp x)
(listp y))
(equal (app (rev x) (rev y))
(rev (app x y))))
by…

user3085077
- 45
- 1
- 1
- 7
0
votes
1 answer
Prove Transitivity in Haskell semantics
I am learning semantics of Haskell and there I came across this question:
I have tried it but still unable to conclude the answer. It will be great if someone explains me how to prove this one. Thank you.

Waqar Ahmed
- 5,005
- 2
- 23
- 45
0
votes
2 answers
Function evaluation result
Im trying to evaluate manually fc [f1, f2] (\x -> 2) 3 but I don't realize how to match the three parameters: [f1, f2], (\x -> 2) and 3 with the function definition, any help?
The function definition:
fc xss = \f -> let ope x y = x . f . y in foldr1…

Fof
- 407
- 2
- 8