Encoding many-valued logic in $lambda$-calculus (Logical Methods in Computer Science, 2021)