Presentation is loading. Please wait.

Presentation is loading. Please wait.

Part-2: Propositional Logic By Dr. Syed Noman Hasany.

Similar presentations


Presentation on theme: "Part-2: Propositional Logic By Dr. Syed Noman Hasany."— Presentation transcript:

1 Part-2: Propositional Logic By Dr. Syed Noman Hasany

2 “The beginning of knowledge is the discovery of something that we do not understand.” –Frank Herbert

3 Knowledge Pyramid Noise Data Information Knowledge Meta- Knowledge Knowledge – the integration of the information into a knowledge base to be effectively utilized Data Data – collected symbols and artifacts Information Information – the interpretation of artifacts in some context Interpretation in Context Integration and Usage raw digital material Data - raw digital material or the “ artifacts which exist as a vehicle for conveying information ” interpreted data Information - interpreted data “ within a context set by a priori knowledge and the current environment ” purposeto information Knowledge - assigns a purpose and/or action to information

4 Knowledge bases Knowledge base = set of sentences in a formal language

5 Knowledge-base System Sys KB percept ask/result tell Knowledge level Logical level Implementation level What it knows Knowledge implementation How it knows Describing a KB... sentences inference engine

6 Propositional Logic The syntax of propositional logic is made up of propositions and connectives.

7 Proposition A statement in some language that can be evaluated to either true or false (but it cannot be both). Example propositions: It is raining. 5 + 5 = 10. Turkey is in Asia. Riyadh is the capital of KSA. Not propositions: Where are you? Oh no! Liverpool is not.

8 Propositions Of the valid propositions, each can be evaluated to either true or false. e.g. It is true that it is raining e.g. It is false that Turkey is in Asia. An easy way to determine whether or not a statement is a proposition is to see if you can prefix it with “it is true that” or “it is false that”; and if it subsequently still makes sense.

9 Propositions we represent propositions using the propositional variables p, q, r etc. The previous examples of propositions are all atomic. We can combine these atomic propositions to form compound propositions…

10 Connectives Propositions are combined through connectives. The main connectives of propositional logic are: Conjunction (and): Λ Disjunction (or): v Negation (not): ¬ Implication (if..then): → Equivalence (if and only if): ↔

11 Material Implication For the implication truth table, p → q is false only when p is true and q is false. The last two cases, where p is false, we cannot say whether q will be true, but as we cannot say it will definitely be false, then we evaluate these cases to true.

12 Implication Example: Using the implication connective we can express that if “you give me your mobile phone” then “I will be your best friend”, as: p → q where p represents the proposition “you give me your mobile phone” and q represents the proposition “I will be your best friend”. pqp → q TTFFTTFF TFTFTFTF TFTTTFTT Truth Table

13 Implication We need to be careful with → as it may not quite capture our intuitions about implication. In particular (taking the previous example), p → q is true in the following situations: –I study hard and I get rich; or –I don't study hard and I get rich; or –I don't study hard and I don't get rich. Note the last two situations, where the implication is true regardless of the truth of p. The one thing we can say is that if I've studied hard but failed to become rich then the proposition is clearly false.

14 Equivalence OR Bi-implication Example: Using the equivalence connective we can express that “Asim will get a first class degree” iff “his average is higher than 70%”, as: p ↔ q where p represents the proposition “Asim will get a first class degree” and q represents the proposition “his average is higher than 70%”. pqp ↔ q TTFFTTFF TFTFTFTF TFFTTFFT Truth Table

15 Compound Statements Connectives can be combined to form compound statements or formulae. e.g.: ¬(p Λ ¬ q) p Λ q ↔ r

16 Example The truth table for ¬(p Λ ¬q) is as follows: pq TTFFTTFF TFTFTFTF ¬q (p Λ ¬q)¬(p Λ ¬q) F T F T F T F F T F T T

17 Example This table is derived by a number of steps: pq TTFFTTFF TFTFTFTF ¬q (p Λ ¬q)¬(p Λ ¬q) F T F T F T F F T F T T

18 Tautologies and Contradictions For the truth tables of some formulae we find only Ts in the last column. Such formulae are called “tautologies” (or valid formulae). Conversely, the truth tables of other formulae contain only Fs in the last column. Such formulae are called “contradictions” (or unsatisfiable formulae). Negation of a tautology is a contradiction, and vice versa. A formula that is neither a tautology nor a contradiction (i.e. contains both Fs and Ts in the last column) is known as a “contingency” (or a satisfiable formula).

19 Tautology Example The truth table for: p → (p V q), is a tautology, as shown below. pq TTFFTTFF TFTFTFTF (p V q) T T T F p → (p V q) T T T T

20 Contradiction Example The truth table for: (p V q) Λ (¬p Λ ¬q), is a contradiction, as shown below. pq TTFFTTFF TFTFTFTF T T T F (p V q)¬p¬q F F T T F T F T ¬p Λ ¬q F F F T (p V q) Λ (¬p Λ ¬q) F F F F

21 Contingency Example The truth table for: (p Λ q) → ¬ p, is a contingency, as shown below. pq TTFFTTFF TFTFTFTF (p Λ q) T F F F ¬p¬p F F T T (p Λ q) → ¬p F T T T

22 Equivalences It is worth noting that there are a number of equivalences between the logical connectives. Thus: p  q is equivalent to ¬p V q p Λ q is equivalent to ¬(¬p V ¬ q) p V q is equivalent to ¬p  q The symbol we use to denote equivalence is: ≡ e.g. p  q ≡ ¬p V q etc.

23 Equivalences pqp → q TTFFTTFF TFTFTFTF TFTTTFTT pq¬p¬p V q TTFFTTFF TFTFTFTF FFTTFFTT TFTTTFTT We can check to see if these statements are equivalent by examining the appropriate truth tables

24 Equivalence Laws There are a number of laws that state equivalence relations. The following are a few of the most popular ones: Associative laws: (p V q) V r ≡ p V (q V r) (p Λ q) Λ r ≡ p Λ (q Λ r) Commutative laws: p V q ≡ q V p p Λ q ≡ q Λ p Involution law: ¬¬p ≡ p

25 Equivalence Laws Distributive laws: p V (q Λ r) ≡ (p V q) Λ (p V r) p Λ (q V r) ≡ (p Λ q) V (p Λ r) DeMorgan’s laws: ¬(p V q) ≡ ¬p Λ ¬q ¬(p Λ q) ≡ ¬p V ¬q All these laws can be verified by checking the appropriate truth tables to see that the statements are equivalent.

26 Syntax semantics

27 Wumpus World description

28 Exploring the Wumpus World 1.The KB initially contains the rules of the environment. 2.(a) [1,1] The first percept is [none, none,none,none,none], Move to safe cell e.g. 2,1 3.(b) [2,1] Breeze indicates that there is a pit in [2,2] or [3,1] Return to [1,1] to try next safe cell

29 Exploring the Wumpus World 4.[1,2] Stench in cell: wumpus is in [1,3] or [2,2] YET … not in [1,1] Thus … not in [2,2] or stench would have been detected in [2,1] Thus … wumpus is in [1,3] Thus … [2,2] is safe because of lack of breeze in [1,2] Thus … pit in [3,1] Move to next safe cell [2,2]

30 Exploring the Wumpus World 5.[2,2] Detect nothing Move to unvisited safe cell e.g. [2,3] 6.[2,3] Detect glitter, smell, breeze Thus… pick up gold Thus… pit in [3,3] or [2,4]

31 Logic in general

32 A Formal Approach Any logic comes in three parts: syntax: what are the well-formed formulae (wffs)? semantics: what do formulae mean, how do we interpret them? deduction: how to mechanically formulate formulae, giving us for instance, the valid ones? Or is concerned with manipulating formulae according to certain rules (Also called the proof theory)

33 Propositional logic grammar S := ; := | ; := "TRUE" | "FALSE" | "P" | "Q" | "S" ; := "(" ")" | |"NOT" ; := "NOT" | "AND" | "OR" | "IMPLIES" | "EQUIVALENT" ;

34 Argument and Proof in Propositional Logic An argument is a relationship between a set of propositions called premises and another proposition called the conclusion. Proof is intended to show deductively that an argument is sound (or valid). –An argument is sound iff it cannot be the case that its premises are true and its conclusion is false. An argument that is not sound is called a fallacy In addition to using truth tables, other forms of proof can be used, such as derivation rules (or proof rules).

35 Entailment and Proof To clarify the difference between entailment and proof: Entailment: if we have a set of formulae which are true, then as a logical consequence of this, some particular formula must also be true. Proof: a formula is provable (derivable) in some logical system if there are rules of inference that allow the formula to be derived by performing some operations on the formulae. Entailment is concerned with the semantics of formulae, proof is concerned with syntax only.

36 Entailment Example: {¬q, p  q} ╞ ¬p means that ¬p is true, iff both ¬q and p  q are true. Thus, the premises entail the conclusion. pq TTFFTTFF TFTFTFTF FFTTFFTT FTFTFTFT TFTTTFTT (p  q) ¬p¬q Truth Table

37 Entailment Lines 1, 2 and 3 all have false truth assignments so we disregard them. This means that we are left with one assignment, where all assignments for the formula are true. –i.e. ¬q is true, p  q is true and ¬p is true. Therefore, ¬p is entailed by {¬q, p  q}, or more formally: {¬q, p  q} ╞ ¬p

38 Modus Ponens (Latin term means) Affirming the antecedent One particularly important derivation rule is modus ponens, as shown on the previous slide. This takes the following form: p → q, p ╞ q Essentially, this argument states that given the premise p → q, and the premise p then we must conclude q.

39 Modus Ponens Example An example argument of the form modus ponens: Premises: - If it is raining then ground is wet (p → q), - It is raining (p), Conclusion: - Therefore, the ground is wet (q).

40 Modus Tollens Denying the consequent Another important derivation rule is modus tollens (also known as the contraposition) have the following form: p → q, ¬q ╞ ¬p Example: Premises: - If it is raining then the ground is wet (p → q), - The ground is not wet (¬q) Conclusion: - Therefore, it is not raining (¬p).

41 Exercise Can we entail otherwise in modus tollens?

42 Soundness and Completeness Two important properties to consider in inference systems are soundness and completeness. A “logic is sound”, with respect to its semantics, if only true formulae are derivable under the inference rules, from premises which themselves are all true. (i.e. the inference rules are correct) A “logic is complete” if all the true formulae are provable from the rules of the logic. (i.e. no other rules are required)

43 Proof System A proof system PS is a set of inference rules. A proof is a sequence of sentences where each sentence can be inferred from a previous sentence using one of the inference rules. A ├ PS B means that there exists a proof starting with A (which might be a set of sentences), ending with B, using the proof system PS.

44 Logical equivalence Two sentences are logically equivalent iff they are true in same models: α ≡ ß iff α╞ β and β╞ α

45 Entailment Entailment means that one thing follows from another: KB ╞ α Knowledge base KB entails sentence α if and only if α is true in all worlds where KB is true

46 Entailment in the wumpus world Situation after detecting nothing in [1,1], moving right, breeze in [2,1] Consider possible models for KB assuming only pits 3 Boolean choices  8 possible models

47 Wumpus models

48 KB = wumpus-world rules + observations

49 Wumpus models KB = wumpus-world rules + observations α 1 = "[1,2] is safe", KB ╞ α 1, proved by model checking

50 Wumpus models KB = wumpus-world rules + observations

51 Wumpus models KB = wumpus-world rules + observations α 2 = "[2,2] is safe", KB ╞ α 2

52 Inference KB ├ i α = sentence α can be derived from KB by procedure i Soundness: i is sound if whenever KB ├ i α, it is also true that KB╞ α Completeness: i is complete if whenever KB╞ α, it is also true that KB ├ i α

53 A simple knowledge base: Wumpus world sentences Let P i,j be true if there is a pit in [i, j]. Let B i,j be true if there is a breeze in [i, j]. α 1 : Is P 1,2 entailed? α 2 : Is P 2,2 entailed? R 1 :  P 1,1 R 4 :  B 1,1 R 5 :B 2,1 "Pits cause breezes in adjacent squares" R 2 :B 1,1  (P 1,2  P 2,1 ) R 3 :B 2,1  (P 1,1  P 2,2  P 3,1 ) (Question: what if  instead of  ? ) ( R 1 ^ R 2 ^ R 3 ^ R 4 ^ R 5 ) is the State of the Wumpus World

54

55 Truth tables for inference KB is true if R1 R1 through R5 R5 are true, which is true in just 3 of 128 rows. In all 3 rows, P 1,2 is false, so there is no pit in [1,2]. On the other hand, there might (or might not) be a pit in [2,2]. Why not sure? All True means “Yes”; All False means “No”; Contingent means “Un-known”

56 Inference Examples KB is true when the rules hold—only for three rows in the table –The three rows are models of KB Consider the value of P 1,2 for these 3 rows –P 1,2 is false in all rows (the rows are models of α 1 =  P 1,2 ) –Thus, there is no pit in room [1,2] Consider the value of P 2,2 for these 3 rows –P 2,2 false in one row, true for 2 rows –Thus, there may be a pit in room [2,2]

57 Resolution Inference Rule The rule is established (when both are true, result is true)

58 Inference Rules for propositional logic 1.Modus Ponens or Implication-Elimination: (From an implication and the premise of the implication, you can infer the conclusion.) 2.And-Elimination: (From a conjunction, you can infer any of the conjuncts.) 3.And-Introduction: (From a list of sentences, you can infer their conjunction.) 4.Or-Introduction: (From a sentence, you can infer its disjunction with anything else at all.) 5.Double-Negation Elimination: (From a doubly negated sentence, you can infer a positive sentence.) 6.Unit Resolution: (From a disjunction, if one of the disjuncts is false, then you can infer the other one is true.)   => ,  i i  1   2  …   n  1,  2, …,  n  1   2  …   n ii      ,          ,       =>    => ,  =>  7.Resolution: (Because  cannot be both true and false, one of the other disjuncts must be true in one of the premises. Equivalently, implication is transitive. a=b, b=c -> a=c) or equivalently

59 Suppose my knowledge base consists of the facts S  T   (  P  R)  S T R And I need to prove that P is entailed. I can use the rules of inference to do this.. S  T   (  P  R),  S, T, RAnd-Introduction S  T   (  P  R),  S  T, R Double Negation Elimination S  T   (  P  R), (S  T), R Modus ponens  (  P  R), RApply negation  P   R, RUnit Resolution  PDouble Negation Elimination P So, P is entailed from the knowledge base.

60 Example: Proof

61 Prove?

62 Proving things The last sentence is the theorem (also called goal or query) that we want to prove. Example for the “weather problem”: 1 Hu Premise“It is humid” 2 Hu  Ho Premise“If it is humid, it is hot” 3 Ho Modus Ponens(1,2)“It is hot” 4 (Ho  Hu)  R Premise“If it’s hot & humid, it’s raining” 5 Ho  Hu And Introduction(1,2)“It is hot and humid” 6 R Modus Ponens(4,5)“It is raining”

63 Logical equivalence Two sentences are logically equivalent iff they are true in same models: α ≡ ß iff α╞ β and β╞ α

64 A simple knowledge base: Wumpus world sentences Let P i,j be true if there is a pit in [i, j]. Let B i,j be true if there is a breeze in [i, j]. α 1 : Is P 1,2 entailed? α 2 : Is P 2,2 entailed? R 1 :  P 1,1 R 4 :  B 1,1 R 5 :B 2,1 "Pits cause breezes in adjacent squares" R 2 :B 1,1  (P 1,2  P 2,1 ) R 3 :B 2,1  (P 1,1  P 2,2  P 3,1 ) (Question: what if  instead of  ? ) ( R 1 ^ R 2 ^ R 3 ^ R 4 ^ R 5 ) is the State of the Wumpus World

65 Back to Wumpus World KB = ( R 1 ^ R 2 ^ R 3 ^ R 4 ^ R 5 ) Prove  P 2,1 Apply Bi-conditional Elim R 6 : (B 1,1 => (P 1,2 V P 2,1 )) ^ ( (P 1,2 V P 2,1 ) => B 1,1 ) Apply And Elim R 7 : ( (P 1,2 V P 2,1 ) => B 1,1 ) Contrapositive R 8 : (  B 1,1 =>  (P 1,2 V P 2,1 )) Apply Modus Ponens with R 4 (  B 1,1 ) R 9 :  (P 1,2 V P 2,1 ) Apply De Morgans R 10 :  P 1,2 ^  P 2,1

66 proved? Finally? –Which rule?

67 Assign: Q.1 Syntax. Say whether each of the following is a sentence of Propositional Logic.

68 Assign: Q.2 Validity, Satisfiability, Unsatisfiability. For each of the following sentences, Indicate whether it is valid, satisfiable, or unsatisfiable..

69 Assign: Q.3 Prove


Download ppt "Part-2: Propositional Logic By Dr. Syed Noman Hasany."

Similar presentations


Ads by Google