Breaking "Provably Correct" Leftpad
19 hours ago
- #programming
- #formal-methods
- #unicode
- The author tests various 'provably correct' implementations of the leftpad function with Unicode strings, revealing inconsistencies.
- Different programming languages handle string length and Unicode characters differently, leading to varied leftpad outputs.
- Formal verification ensures code matches specifications, but specifications may not align with real-world expectations or Unicode complexities.
- Swift's implementation, generated by ChatGPT, aligns closest with the author's expected output, highlighting the challenges in defining 'correct' behavior.
- The post underscores the difficulty in programming with Unicode, the importance of clear specifications, and the limitations of formal methods.