霍尔逻辑:一种用于形式化证明程序正确性的方法,核心是用“三元组”来描述程序片段在给定前提下执行后会满足的结果:
{P} C {Q},其中 P 是前置条件(precondition),C 是程序/命令(command),Q 是后置条件(postcondition)。常用于程序验证、静态分析与形式化方法中。(也常称 Hoare calculus / Hoare system)
/hɔːr ˈlɒdʒɪk/
Hoare logic helps us prove that a program does what it claims.
霍尔逻辑帮助我们证明一个程序确实实现了它所宣称的功能。
Using Hoare logic, we can specify invariants and show that the loop maintains them until the postcondition is satisfied.
使用霍尔逻辑,我们可以给出不变式并证明循环在执行过程中保持它们,直到满足后置条件。
“Hoare”来自英国计算机科学家 C. A. R. Hoare(托尼·霍尔) 的姓氏;他在 1969 年提出以公理化方式推理程序的框架(Hoare triples)。 “logic”表示其推理规则与证明体系的逻辑性质,因此合称 Hoare logic(霍尔逻辑)。