The kata is inspired by a Stack Overflow question.
It is easy to prove that f(f(f b)) = f b
for all functions f : bool -> bool
. But can you do it in less than 92 characters?
More specifically, your task is to prove the following lemma:
Lemma lemma : forall (f : bool -> bool) (b : bool), f (f (f b)) = f b
.
And the size of your solution (including all declarations) should be 91 characters or less.
This challenge comes from monadius on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!
Top comments (7)
Here's my solution in Coq:
The second line has 80 characters.
Not a code golfer, but pretty compact with writing the way I learned in uni:
Above code is 82 characters, excluding whitespace.
EDIT: now in LaTeX
Another proof in Isabelle/HOL
In Isabelle/HOL
You have a typo in the lemma statement, f is applied twice instead of three times.
In Isabelle/HOL equivalent to the above but with a different notation
And with another notation