Upcoming SlideShare
×

# Propositional logic is a good vehicle to introduce basic properties of logic

915 views

Published on

propositional logic

Published in: Education, Technology
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

• Be the first to like this

Views
Total views
915
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
21
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Propositional logic is a good vehicle to introduce basic properties of logic

1. 1. Logic in computer sience Propositional logic is a good vehicle to introduce basic properties of logic. It does not provide means to determine the validity (truth or false) of atomic statements. Instead, it allows you to evaluate the validity of compound statements given the validity of its atomic components. For example, consider the following: I like Pat or I like Joe. If I like Pat then I like Joe. Do I like Joe? Accept as facts the first two statements, noting that the use of "or" here is not exclusive and thus could really be thought of as saying "I like Pat, or I like Joe, or I like them both". Do these statements imply that "I like Joe" is true? Try to convince yourself that "I like Joe" is true, and consider another line of reasoning: Pigs can fly or fish can sing. If pigs can fly then fish can sing. Can fish sing? We can see that the answer is yes in both cases. The above two sets of statements can be both abstracted as follows: Q? Here, we are concerned about the logical reasoning itself, and not the statements. Thus, instead of working with pigs or Pats, we simply write Qs or Ps. We begin our study first with the syntax of propositional logic: that is, we describe the elements in our language of logic and how they are written. We then describe the semantics of these symbols: that is, what the symbols mean.  Syntax The syntax of propositional logic is composed of propositional symbols, logical connectives, and parenthesis. Rules govern how these elements can be written together. First, we treat propositional symbols merely as a set of some symbols, for our purposes we'll use letters of the Roman and Greek alphabets, and refer to the set of all symbols as Prop: Propositional symbols: A set Prop of some symbols. For example Second, we have the logical connectives:
2. 2. Logical connectives: Note that these are not the minimal required set; they can be equivalently represented only using the single connective NOR (not-or) or NAND (not-and) as is used at the lowest level in computer hardware. Finally, we use parenthesis to denote expressions (later on we make parenthesis optional): Parentheses: (,) An expression is a string of propositional symbols, parenthesis, and logical connectives. The expressions we consider are called formulas. The set Form of formulas is the smallest set of expressions such that: 1. 2. If then 1. , 2. , 3. , and 4. . Another way to define formulas is as the language defined by the following context-free grammar (with start symbol Form): , where Prop stands for any propositional symbol Fact 1 (Unique Readability): The above context free grammar is unambiguous.  Semantics The function of a formula is to create meanings of statements given meanings of atomic statements. The semantics of a formula φ with propositional symbols is a mapping associating to each truth assignment V to a truth value (0 or 1) for φ. (The truth values true and false can be used instead of 1 or 0, respectively, as well as the abbreviations T and F.) The semantics are well defined due to Fact 1. One way to specify semantics of a logical connective is via a truth table:
3. 3. p q 0 0 0 0 1 0 1 0 0 1 1 1 Can one always find a formula that implements any given semantics? Yes, any truth table is realized by a formula. The formula can be found as follows. "Represent" the rows where φ = 1 with conjunctions of the true proposition symbols and negations of the false ones. Finally write the disjunction of the results. For example, p q φ Conjunctions (true values only) 0 0 1 0 1 0 1 0 1 1 1 0 Corollary: Every formula is equivalent to a disjunction of conjunctions of propositional symbols or negation of propositional symbols (DNF). Dual of DNF is CNF. To get φ in CNF: 1. Describe cases when φ is false. ex - DNF ψ 2. Note that φ is true when is false. Hence, negate ψ using DeMorgan's laws. ex . There are cases when DNF (resp. CNF) is exponentially larger than the original formula. For example, for the equivalent DNF is exponential in size. Does each truth table have a polynomial size formula implementing it? More precisely, does there exist k such that every truth table with n propositional symbols has a form φ of size ? Answer: no.
4. 4. Proof: Assume there exists such k. The number of truth tables for n propositional symbols is . The number of formulas of size is (n propositional symbols, 4 connectives and parentheses.) Clearly, , for sufficiently large n. [TODO: exposition to explain what these definitions are and provide their context]  Satisfaction: Satisfaction of a formula φ by a truth assignment τ. Notation: (φ is true for τ).  Implication: A set of formulas Σ implies φ. Notation: . Σ implies φ if and only if every truth assignment that satisfies Σ also satisfies φ.  Formula Classes of Special Interest  VALID - the set of formulas that are always true (also known as tautologies). For example, are valid formulas.  UNSAT - the set of formulas that are never true (unsatisfiable).  In between: SAT - the set of formulas for which there exists a satisfying assignment (not unsatisfiable). Note. . Claim: Claim: SAT is NP-complete. Proof:  : guess a satisfying assignment, then verify that the formula is true (a satisfying assignment is a certificate).  Hardness. graph 3-coloring (there also exists a direct proof). We reduce 3- coloring to SAT. Let G = (V,E) be a graph with n nodes . We use propositional variables pi,g,pi,r,pi,b to indicate that vertex i is colored with green, red, or blue. Construct φ as follows: Claim: . It is also possible to prove that directly
5. 5. Claim: .  Horn Clauses Special case for which SAT is in polynomial time. Example: A Horn clause is a disjunction of literals of which at most one is positive. There are two kinds of possible Horn clauses: 1. clause has 1 positive literal 1. p, or 2. 2. no positive literal 1. 2. Claim: For every set Σ of Horn formulas, checking whether Σ is satisfiable is in P. Proof Idea: Let Σ1 be the subset of Σ containing only clauses of type 1, and Σ2 the subset of Σ containing clauses of type 2. Note first that Σ1 is satisfiable. To obtain a minimum satisfying assignment σ, start with literals from single-literal clauses and crank the rules. It now remains to check consistency of σ with the clauses in Σ2. To do this, it is enough to check that for each clause in Σ2, σ is not true for all of . Example: Consider the set Σ of Horn clauses: p q r The set Σ1 of clauses of type 1 consists of the first 5 clauses, and Σ2 consists of the last clause. Note that Σ1 can also be written as: p q r The minimum satisfying assignment for Σ1 is obtained as follows:
6. 6. 1. start with {p,q,r} 2. use the first implication to infer s 3. use the second implication to infer t Thus, the minimum satisfying assignment makes {p,q,r,s,t} true. This contradicts Σ2, which states that t must be false. Thus, Σ is not satisfiable.  Deductive Systems A deductive system is a mechanism for proving new statements from given statements. Let Σ be a set of known valid statements (propositional formulas). In a deductive system, there are two components: inference rules and proofs. Inference rules An inference rule indicates that if certain set of statements (formulas) is true, then a given statement must be true. An inference rule H is denoted as . Example (modus ponens): Proofs A proof of from Σ is sequence of formulas such that and for all  Each formula , or  There are a subset of formulas , such that, is an inference rule. If has a proof from Σ using inference rule H we write . Properties:  Soundness: If then (i.e., all provable sentences are true). This property is fundamental for the correctness of the deductive system.  Completeness: If then (i.e., all true sentences are provable). This is a desirable property in deductive systems.  Natural Deduction Natural deduction is a collection of inference rules. Let denote contradiction, falsity. The following are the inference rules of natural deduction:
7. 7. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13.
8. 8. 14. 15. 16. Rule (13) allows us to prove valid statements of the form "If then ψ" even if we don't know the truth value of the statement (i.e., is not in the set Σ of known valid statements). Indeed, for this rule, we start assuming is valid. If we can conclude ψ is valid in a world where are valid, then we conclude that the relation is true, and we "release" the assumption is valid. We now show how to apply the above inference rules. Example: De Morgan's Law for negated or-expressions says: Proof: By rule (8) if we can prove and we can infer the desired result. To prove the first direction, we use rule 13 and assume the hypothesis . Then
9. 9. (assumed) (assumed) (by rule 11) (by rule 5) (by rule 14) ψ (assumed) (by rule 11) (by rule 5) (by rule 14) (by rule 1) (by rule 13) We now prove the second direction. (assumed) (by rule 2) (by rule 3) (assumed) (assumed) (by rule 5) (by rule 16) (by rule 14) (by rule 13) Proof of Pierce's Law: . (assumed) (1*) (assumed) A (assumed) (by rule 5) B (by rule 7) (by rule 13) A (by assumption (1*) and rule 4) (by rule 5) A (by rule 14) (by rule 13) Fact 2: Natural deduction is sound. To show that natural deduction is also complete we need to introduce propositional resolution.  Propositional Resolution
10. 10. Resolution is another procedure for checking validity of statements. It involves clauses, formulas and a single resolution rule. Some terminology: Clause A clause is a propositional formula composed by disjunction of literals. For example . It is usually denoted as the set of literals, e.g. . The empty clause, denoted as an open box " ", is the disjunction of no literals. It is always false. Formula A set of clauses, each of them satisfiable. For example, represents the CNF formula . The empty formula, denoted as , is the set that contains no clauses. It is always true. Resolution Rule It is a rule that, given two clauses C (containing some literal y) and C' (containing some literal ), allows to infer a new clause, called the resolvent of C and C' (with respect to y). A proof system for resolution contains a single resolution rule, where the resolvent is defined as follows. Assume C and C' are clauses such that and , then . The smallest set of clauses containing and closed under resolution is denoted . Example: If C = {p,y} and , then resy(C,C') = {p,q}. It is possible to show that the resolution rule, as defined, computes a clause that can be inferred using natural deduction. Claim: Let C and C' be any two clauses such that and . Then . In order to prove the validity of a statement ψ, we will prove the negated statement is unsatisfiable. To prove unsatisfiability of a formula , we need to define the resolution refutation of the formula : The resolution refutation tree of the formula is a tree rooted at the empty clause, where every leaf is a clause in and each internal node is computed as the resolvent of the two corresponding children. Notice that clauses of can appear repeated as leaves. From above claim we can conclude that:
11. 11. Claim: If there exists a resolution refutation tree for formula , then , that is, is unsatisfiable. Example: The formula has the following resolution refutation tree: The order in which clauses are selected to compute the resolvent matters when computing the resolution refutation tree, as the following example shows: Consider the formula . Even though a resolution refutation tree may exist for ψ, order is important when trying to build the tree. Below are two different resolution refutation trees, but only one is successful: Unsuccessful attempt of resolution refutation tree for ψ.
12. 12. A successful resolution refutation tree for ψ.  Properties of Propositional Resolution Soundness: Propositional resolution is sound, that is, if there exists a resolution refutation tree for a given formula , then must be unsatisfiable. Theorem: For any formula , if , then . Completeness: Propositional resolution is complete, that is, if a given formula is unsatisfiable, then has a resolution refutation tree. Theorem: For any formula , if , then . Proof: By induction on the number of variables in . Basis: We have one variable, say p. All possible clauses of are {p} and . If is unsatisfiable then both clauses occur, and therefore . Induction step: Suppose the hypothesis is true for formulas with less than n variables. Let be a formula with n variables. Suppose ; we will show is satisfiable. Let p be a variable of . Then either or (if both hold then immediately). Assume . We define the formula as containing all clauses that do not contain {p} and where the literal has been removed from each clause (in other words, is equivalent to the formula resulting from setting p true). Formally, . First, notice that
13. 13. and thus, . Also, since we have that . By the induction hypothesis, is satisfiable. Then is satisfiable by an extension of the satisfying assignment of with p equal true. The case is analogous.  Completeness of Natural Deduction Theorem: Let H be the set of inference rules of Natural Deduction. If then . The idea behind the proof of completeness of natural deduction is as follows. Suppose is valid (then is unsatisfiable). We then show there exists a resolution refutation for and then by applying the contradiction rule (rule 15): we conclude can be inferred. Proof: (Sketch) Given a formula valid under Σ, we perform the following steps: 1. Prove that is equivalent to some ψ, where ψ is in CNF. 2. Prove that , for all ψ. 3. By completeness of resolution, if ψ is unsatisfiable then . Therefore, {p} and for some literal p. This implies . 4. Conclude that and therefore is valid. Step (1) can be easily done by repeated application of De Morgan's laws. Step (2) can be proven using natural deduction. Finally, step (3) can be proven by induction on the number of steps to obtain Res(ψ). Clearly, each step can be simulated using natural deduction. It is very likely that any algorithm for propositional resolution will take very long on the worst case (recall that checking validity of a formula is co-NP complete).  Linear Resolution and PROLOG
14. 14. Linear resolution is a particular resolution strategy that always resolves the most recent resolvent with a clause. The resolution refutation tree so obtained is therefore linear. It is possible to prove that, if the set of clauses are Horn clauses, there exists a linear resolution strategy for any formula. That is, linear resolution is complete for the set of Horn clauses. The language PROLOG uses resolution on a set of Horn clauses. Each clause is called a program clause. Moreover, clauses composed by a single literal are called facts. A clause with a single negated literal is called a query. The table below shows a comparison of the different notations. In PROLOG, to query a statement t, the idea is to negate the statement ( ) and to perform resolution with the set of known true statements. If a resolution refutation tree is found, the statement t is implied by the program. Example: An example of linear resolution for the formula is shown here: