1 / 57

Logic

Logic. Logic is concerned with mechanizing reasoning Logic is used to determine whether the truth of the conclusion follows necessarily from truth of preceding statements Logic is used to analyze the form of arguments, not to determine the merits of the argument’s content.

shandi
Download Presentation

Logic

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Logic • Logic is concerned with mechanizing reasoning • Logic is used to determine whether the truth of the conclusion follows necessarily from truth of preceding statements • Logic is used to analyze the form of arguments, not to determine the merits of the argument’s content

  2. Propositional logic • A proposition is a statement that is true or false but not both Examples: • The Linus room cooling system in GCCIS is in shut-down mode • The GCCIS SE department Employee file has been created. The following are not propositions: • You will be an expert at the end of this course

  3. Model-based semantics for propositional logic • A state is an assignment of truth values (true, false) to boolean variables. • The value of a boolean expression in a state is determined by truth tables. • A boolean expression is satisfied in a state if its value is true in that state. • A boolean expression is satisfiable if there is a state in which it is satisfied. • A boolean expression is valid if it is satisfied in every state. A valid expression is called tautology.

  4. Identifying problems in specifications • Formalizing helps identify ambiguities If the inlet valve is open, then the system is switched to OPEN and the outlet valve is closed if the monitoring system is functioning Form 1:invalveopen => (sysfunct => open ⋀ outletclosed) Form 2:invalveopen => (open ⋀ (sysfunct => outletclosed) • Specifications can help frame questions: AlertState => NormalAlert ⋁ practice NormalAlert ⋀ Monitortyped => error1 practice ⋀ MonitorTyped => error1 Q. If the system is in alert state and the operator typed in MONITOR command, would an error1 occur? Q. What events cause an error1?

  5. Identifying problems in specifications • Identifying inconsistencies The system is in alert state only when it is waiting for an intruder and is on practice alert alert <=> waiting ⋀ practice If the system is in teaching mode and is on practice alert, then it is in alert state. The system will be in teaching mode and on practice alert and not waiting for an intruder teaching ⋀ practice => alert teaching ⋀ practice ⋀~waiting

  6. Predicate logic Terms + Predicate : IsHome(a) • Predicate logic assumes that the world consists of individual objects which may have certain properties and between which certain relations may hold Propositional logic cannot be used to reason about classes of objects For example, from the statements, All monitoring computers are ready. X12 is a monitoring computer. One cannot infer that X12 is ready. using propositional logic

  7. Predicates, functions, and formulas • A function maps objects to other objects Example:N x N →N • A predicate is a function that returns a true or false value Example: N x N →boolean • Predicate logic formulas include boolean expressions, and formulas of the form: • ∀a: A● P (unrestricted universal quantifier) • ∀a: A | R● P (restricted universal quantifier) • ∃a: A● P (unrestricted existential quantifier) • ∃a: A | R ● P (restricted existential quantifier)

  8. Proposition • Logic: study of reasoning, whether the relations among statements are correct • Proposition: a sentence is true or false • Declarative, compositional, context independent • Compound proposition: • conjunction pq • disjunction pq • negation • conditional p (hypothesis)  q (conclusion) : if then • Bi-conditional p  q: if and only if

  9. Proposition logicUsing truth table to verify their correctness -- always have the same truth valueProof logically equivalent

  10. Tautologies, contradictions, contingencies A compound proposition is called a tautology if no matter what truth values its atomic propositions have, its own truth value is T. p ¬p (Law of excluded middle) The opposite to a tautology, is a compound proposition that’s always false –a contradiction. p ¬p On the other hand, a compound proposition whose truth value isn’t constant is called a contingency. p ¬p

  11. p p p p p p p p F T F T T F T F T T F F Tautologies and contradictions The easiest way to see if a compound proposition is a tautology/contradiction is to use a truth table.

  12. Tautology example Demonstrate that [¬p(p q )]q is a tautology in two ways: • Using a truth table – show that [¬p(p q )]q is always true • Using a proof (will get to this later)

  13. Tautology by truth table

  14. Tautology by truth table

  15. Tautology by truth table

  16. Tautology by truth table

  17. Tautology by truth table

  18. Logical Equivalences Two compound propositions p, q are logically equivalent if their biconditional joining p q is a tautology. Logical equivalence is denoted by p q. The contrapositive of a logical implication is the reversal of the implication, while negating both components. i.e. the contrapositive of pq is ¬q¬p . As we’ll see next: pq¬q¬p

  19. p q p q p q ¬q ¬p ¬q¬p Logical Equivalence of Conditional and Contrapositive The easiest way to check for logical equivalence is to see if the truth tables of both variants have identical last columns: Q: why does this work given definition of  ?

  20. p q p q p q ¬q ¬p ¬q¬p T T F F T F T F T F T T Logical Equivalence of Conditional and Contrapositive The easiest way to check for logical equivalence is to see if the truth tables of both variants have identical last columns: Q: why does this work given definition of  ?

  21. p q p q p q ¬q ¬p ¬q¬p T T F F T F T F T F T T T T F F T F T F Logical Equivalence of Conditional and Contrapositive The easiest way to check for logical equivalence is to see if the truth tables of both variants have identical last columns: Q: why does this work given definition of  ?

  22. p q p q p q ¬q ¬p ¬q¬p T T F F T F T F T F T T T T F F T F T F F T F T Logical Equivalence of Conditional and Contrapositive The easiest way to check for logical equivalence is to see if the truth tables of both variants have identical last columns: Q: why does this work given definition of  ?

  23. p q p q p q ¬q ¬p ¬q¬p T T F F T F T F T F T T T T F F T F T F F T F T F F T T Logical Equivalence of Conditional and Contrapositive The easiest way to check for logical equivalence is to see if the truth tables of both variants have identical last columns: Q: why does this work given definition of  ?

  24. p q p q p q ¬q ¬p ¬q¬p T T F F T F T F T F T T T T F F T F T F F T F T F F T T T F T T Logical Equivalence of Conditional and Contrapositive The easiest way to check for logical equivalence is to see if the truth tables of both variants have identical last columns: Q: why does this work given definition of  ?

  25. Logical Equivalences A: p q by definition means that p q is a tautology. Furthermore, the biconditional is true exactly when the truth values of p and of q are identical. So if the last column of truth tables of p and of q is identical, the biconditional join of both is a tautology.

  26. Derivational Proof Techniques When compound propositions involve more and more atomic components, the size of the truth table for the compound propositions increases Q1: How many rows are required to construct the truth-table of:( (q(pr))  ((sr)t) )  (qr) Q2: How many rows are required to construct the truth-table of a proposition involving n atomic components?

  27. Derivational Proof Techniques A1: 32 rows, each additional variable doubles the number of rows A2: In general, 2n rows Therefore, as compound propositions grow in complexity, truth tables become more and more unwieldy. Checking for tautologies/logical equivalences of complex propositions can become a chore, especially if the problem is obvious.

  28. Derivational Proof Techniques consider the compound proposition (p p )  ((sr)t) )  (qr) Why is this a tautology?

  29. Derivational Proof Techniques A: Part of it is a tautology (p p ) and the disjunction of True with any other compound proposition is still True: (p p )  ((sr)t ))  (qr ) • T  ((sr)t ))  (qr ) • T Derivational techniques formalize the intuition of this example.

  30. Identity laws Like adding 0 Domination laws Like multiplying by 0 Idempotent laws Delete redundancies Double negation “I don’t like you, not” Commutativity Like “x+y = y+x” Associativity Like “(x+y)+z = y+(x+z)” Distributivity Like “(x+y)z = xz+yz” De Morgan Tables of Logical Equivalences

  31. Excluded middle Negating creates opposite Definition of implication in terms of Not and Or Tables of Logical Equivalences

  32. DeMorganLaw DeMorgan’slaw allow for simplification of negations of complex expressions • Conjunctional negation: (p1p2…pn)  (p1p2…pn) “It’s not the case that all are true iff one is false.” • Disjunctional negation: (p1p2…pn)  (p1p2…pn) “It’s not the case that one is true iff all are false.”

  33. Tautology example Demonstrate that [¬p(p q )]q is a tautology in two ways: • Using a truth table (did above) • Deriving True through a series of logical equivalences

  34. Tautology by proof [¬p(p q )]q

  35. Tautology by proof [¬p(p q )]q [(¬pp)(¬pq)]q Distributive

  36. Tautology by proof [¬p(p q )]q [(¬pp)(¬pq)]q Distributive [ F (¬pq)]q ULE

  37. Tautology by proof [¬p(p q )]q [(¬pp)(¬pq)]q Distributive [ F (¬pq)]q ULE [¬pq ]q Identity

  38. Tautology by proof [¬p(p q )]q [(¬pp)(¬pq)]q Distributive [ F (¬pq)]q ULE [¬pq ]q Identity ¬[¬pq ] q ULE

  39. Tautology by proof [¬p(p q )]q [(¬pp)(¬pq)]q Distributive [ F (¬pq)]q ULE [¬pq ]q Identity ¬[¬pq ] q ULE [¬(¬p)¬q ] q DeMorgan

  40. Tautology by proof [¬p(p q )]q [(¬pp)(¬pq)]q Distributive [ F (¬pq)]q ULE [¬pq ]q Identity ¬[¬pq ] q ULE [¬(¬p)¬q ] q DeMorgan [p ¬q ] q Double Negation

  41. Tautology by proof [¬p(p q )]q [(¬pp)(¬pq)]q Distributive [ F (¬pq)]q ULE [¬pq ]q Identity ¬[¬pq ] q ULE [¬(¬p)¬q ] q DeMorgan [p ¬q ] q Double Negation p [¬q q ]Associative

  42. Tautology by proof [¬p(p q )]q [(¬pp)(¬pq)]q Distributive [ F (¬pq)]q ULE [¬pq ]q Identity ¬[¬pq ] q ULE [¬(¬p)¬q ] q DeMorgan [p ¬q ] q Double Negation p [¬q q ]Associative p [q ¬q ]Commutative

  43. Tautology by proof [¬p(p q )]q [(¬pp)(¬pq)]q Distributive [ F (¬pq)]q ULE [¬pq ]q Identity ¬[¬pq ] q ULE [¬(¬p)¬q ] q DeMorgan [p ¬q ] q Double Negation p [¬q q ]Associative p [q ¬q ]Commutative p T ULE

  44. Tautology by proof [¬p(p q )]q [(¬pp)(¬pq)]q Distributive [ F (¬pq)]q ULE [¬pq ]q Identity ¬[¬pq ] q ULE [¬(¬p)¬q ] q DeMorgan [p ¬q ] q Double Negation p [¬q q ]Associative p [q ¬q ]Commutative p T ULE T Domination

  45. Example “I don’t drink and drive” is logically equivalent to “If I drink, then I don’t drive”

  46. First order logic • Propositional logic: assume world contains facts • First order logic: assume world contains: • object • relations • functions • High order logic: quantifier and variable can be functions

  47. Basic Elements of First Order Logic • Constants KingJohn, 2, NUS,... • Predicates Brother, >,... • Functions Sqrt, LeftLegOf,... • Variables x, y, a, b,... • Connectives , , , ,  • Equality = • Quantifiers , 

  48. Atomic Sentences Atomic sentence = predicate (term1,...,termn) or term1 = term2 Term = function (term1,...,termn) or constant or variable • An atomic sentence predicate(term1,...,termn) is true iffthe objects referred to by term1,...,termn are in the relation referred to by predicate

More Related