A Sound Strategy to Compile General Recursion into Finite Depth Pattern Matching - Amaro, Maycon J. J.; Feitosa, Samuel S.; Ribeiro, Rodrigo G. (Anais do Simpósio Brasileiro de Métodos Formais (SBMF), 2022)
Programming languages are popular and diverse, and the convenience of programmatically changing the behavior of complex systems is attractive even for the ones with stringent security requirements, which often impose restrictions on the acceptable programs. A very common restriction is that the program must terminate, which is very hard to check because the Halting Problem is undecidable. In this work, we proposed a technique to unroll recursive programs in functional languages to create terminating versions of them. We prove that our strategy itself is guaranteed to terminate. We also formalize term generation and run property-based tests to build confidence that the semantics is preserved through the transformation. Our strategy can be used to compile general purpose functional languages to restrictive targets such as the eBPF and smart contracts for blockchain networks.