I have searched for a while, but cannot find a concise definition on “predicate checking”. When can we apply predicate checking? How does it compare to Hoare’s triple? I think if we apply Hoare’s triple to every line of code correctly, we can guarantee the software’s correctness. (Please correct me if I am wrong.) Can predicate checking gives the same property? I apologize if the question itself is mal-formed. I really don’t know what does predicate checking do.
Share
A Predicate is a logic statement or function that equates to true or false result.
The simplest examples of a predicates in both procedural and declarative languages are guard clauses and assertions e.g.
The pre-condition and post-condition in Hoare are examples of Predicates. I don’t think there is anything explicit in Hoare about the granularity of the encapsulated statement, provided it has single exit path into the post-condition. It could be single statement, a function or an entire process.
Invariants are special case of predicates, where the post-condition = pre-condition.
Perhaps the purest example of this is Prolog, where every statement is a predicate. Another example is design-by-contract as used in Eiffel, and the empty list in LISP is also predicate.
I’d be reluctant to agree with “guarantee the software’s correctness”, with out the qualification that correctness is compliance to the predicates.
Update
predicates.
Post-condition predicates.