COMS E6998 Formal Verification of System Software
Fall 2018
Ronghui Gu
Propositional logic involves only declarative statements.
Declarative statements can be declared to be either true or false (but not both).
Not all statements are declarative. The following cannot be declared true/false.
Complex propositions can be constructed by simple ones using operators.
: “If the train is late and there are no taxis in the station, then Bob is late to work.”
We can examine whether such propositions are true or false when we know the values of the basic propositions.
English (or any human language) is imprecise and subtle (verb tenses, etc.) and error prone. A more mathematical language for logic would make the above arguments clear (Propositional Logic).
To be rigorous, we need to define grammar (or meta-) variables that stand for any term derivable from the grammar:
Definition The logical formulas of Propositional Logic are exactly those accepted by the following grammar in Backus Naur Form (BNF):
We can draw a parse tree for the formula.
Now we are going to look at the truth values of propositional logic formulas . We will write this as
Definition
A model of the formula can be any of the following:
We can write truth tables of composed operators using multiple columns.
Q: Create the truth table of the formula:
Q: Give a model that makes the above formula true.
Definition
Q: which of the above are properties of
Q: show that if is satisfiable then is satisfiable.
Q: Let be valid. Is it necessary that is satisfiable?
Our goal is to use the logic to derive logical conclusions from logical premises (assumptions).
Two ways to do this:
Definition We write “” to mean that any valuation giving to all the value also gives the value .
This is called semantic entailment.
Lemma
is valid iff .
Lemma
is invalid iff .
Lemma
iff .
Lemma
iff .
Lemma
iff or .
Q: show
Proof.
T | T | T | T |
T | F | F | _ |
F | F | T | T |
F | T | F | _ |
Q: show
Proof.
Three different entailments:
There is a standard calculus for axioms of this form called Natural Deduction
Inference rules: If we have formulas then we can derive formula .
Examples:
Axiom (∧i)
If we have any formulas and then we can derive the formula
Axiom (∧e1) If we have formula then we can derive the formula
Axiom (∧e2) If we have formula then we can derive the formula
Q: Prove “” using above axioms.
Simple inference rules: given formulas derive a formula
Complex inference rules: given proofs and formulas derive a formula
The introduction rules of are simple rules.
The elimination rules of are complex rules.
Q: show
Elimination of (aka modus ponens)
Q: show
Q: show
Introduction of : “If we can prove by assuming , then implies .”
Q: show
Q: show ⊢ p → q → p
Thus, we can replace “all the proofs” with “implications”.
If we prove then we can use in our proofs a derivable rule (aka a theorem)
For example, we can prove the following theorem (called modus tollens)
Writing contradictions in the logic:
We will pick an atomic proposition (say ) and name the following:
We will allow to introduce from any contradiction.
To introduce a negation we must show that from we can derive bottom (a contradiction).
Finally, from bottom we are allowed to derive anything:
Q: show
Q show
We know that , for any . That is, .
Can we derive:
Can we derive:
Q: Is every provable statement valid according to the semantics of the logic?
In other words is the proof system sound?
Theorem (Soundness of proof rules)
For any provable statement it is valid that .
Proof by a form of induction.
Q: Do we have enough proof rules so that, any valid , we can be proved syntactically as ? In other words is the proof system complete?
Theorem (Completeness of proof rules)
For any valid sequent it is provable that .
Proof:
Q: is it possible to write an algorithm that decides whether is a valid sequent?
We only need an algorithm to decide whether :
by a theorem, is equivalent to
by soundness and completeness, is equivalent to .
There are many ways to do this. One is to turn formulas into Conjunctive Normal Form (CNF).
CNF is a a formula which has the following structure:
Example:
CNF formulas do not contain:
A CNF formula is valid iff every clause contains a literal and its negation. (Why?)
Valid formulas:
Not valid formulas:
The above gives an efficient algorithm to check validity of CNF formulas (O(n) to the size of the formula).
Every fomula can be transformed to an equivalent CNF formula by the following method:
and
over or
: The above conversion outputs in the worst case an exponentially large formula (O(2n) to the size of the input formula).
Convert to CNF and check the validity of the formulas:
Satisfiability: Given , is there a model which makes true? Q: Can we decide satisfiability?
Theorem
The satisfiability problem is decidable, and NP-complete
So there are known algorithms but they are not efficient in the worst case.
SAT is the first problem that was proven to be NP-complete; see Cook–Levin theorem. This means that all problems in the complexity class NP, which includes a wide range of natural decision and optimization problems, are at most as difficult to solve as SAT. There is no known algorithm that efficiently solves each SAT problem, and it is generally believed that no such algorithm exists; yet this belief has not been proven mathematically, and resolving the question of whether SAT has a polynomial-time algorithm is equivalent to the P versus NP problem, which is a famous open problem in the theory of computing.
The exponential time hypothesis asserts that no algorithm can solve 3-SAT (or indeed k-SAT for any k > 2) in exp(o(n)) time (i.e., fundamentally faster than exponential in n).
Algorithms for Satisfiability
Given a sentence in CNF, how can we prove it is
satisfiable?
If we assign , we get
The result is
This algorithm is called DPLL, which stands for the names of the inventors of the algorithm (Davis, Putnam, Logeman and Loveland).
Properties of satisfiability algorithms:
Other algorithms: GSAT, WALKSAT,…
But there are efficient algorithms for a some CNF formulas: Horn clauses
A CNF formula is a horn formula if all its clauses have at most one positive literal:
Algorithm: Inputs a Horn formula and maintains a list of literals, , and in the formula.
It marks the literals in this list as follows:
This is a O(n) algorithm.
Q: show