leetcode 就是大量的测试用例. 不过这个答案 OP 可能不想听.
可以参考
https://www.lix.polytechnique.fr/Labo/Samuel.Mimram/teaching/INF551/course.pdfBut how can we achieve this goal of applying techniques of proofs to programs?
It turns out that we do not even need to come up with some new ideas thanks to
the so-called proof-as-program correspondence discovered in the 1960s by Curry
and Howard: a program is secretly the same as a proof! More precisely, in a
typed functional programming language, the type of a program can be read as
a formula, and the program itself contains exactly the information required to
prove this formula. This is the one thing to remember from this course:
PROGRAM = PROOF
简译:
怎么校验程序.
感谢 Curry 和 Howard 在 1960s 发明的证明(名词)作为程序的对应关系, (我们不用充钱买 IDEA 了(划掉)):
程序和证明(名词)其实是一样的!
准确地说, 一个有类型的函数式编程语言, 程序的类型可以看成是公式, 而程序的存在就是这个公式所需的证明(动词).
只需记住一点就是:
程序=证明(名词)
对了, 这本书的导论的第一节的标题就是 Proving instead of testing(证明而不是测试)