Introduction to Logic Introduction I Introduction II Examples I Examples II Logical Connectives

Introduction to Logic Introduction I Introduction II Examples I Examples II Logical Connectives

Introduction I Introduction to Logic Propositional calculus (or logic) is the study of the logical Slides by Christopher M. Bourke relationship between objects called propositions and forms the Instructor: Berthe Y. Choueiry basis of all mathematical reasoning and all automated reasoning. Definition Fall 2007 A proposition is a statement that is either true or false, but not both (we usually denote a proposition by letters; p, q, r, s, . .). Computer Science & Engineering 235 Introduction to Discrete Mathematics Sections 1.1-1.2 of Rosen [email protected] Introduction II Examples I Definition Example (Propositions) The value of a proposition is called its truth value; denoted by T or Today is Monday. 1 if it is true and F or 0 if it is false. I I The derivative of sin x is cos x. Opinions, interrogative and imperative sentences are not I Every even number has at least two factors. propositions. Truth table: Example (Not Propositions) p 0 I C++ is the best language. 1 I When is the pretest? I Do your homework. Examples II Logical Connectives Connectives are used to create a compound proposition from two Example (Propositions?) or more other propositions. I Negation (denoted ¬ or !) I 2 + 2 = 5 I And (denoted ∧) or Logical Conjunction I Every integer is divisible by 12. I Or (denoted ∨) or Logical Disjunction I Microsoft is an excellent company. I Exclusive Or (XOR, denoted ⊕) I Implication (denoted →) I Biconditional; “if and only if” (denoted ↔) Negation Logical And The logical connective And is true only if both of the propositions A proposition can be negated. This is also a proposition. We are true. It is also referred to as a conjunction. usually denote the negation of a proposition p by ¬p. Example (Logical Connective: And) Example (Negated Propositions) I It is raining and it is warm. I Today is not Monday. √ I (2 + 3 = 5) ∧ ( 2 < 2) I It is not the case that today is Monday. I Schr¨odinger’s cat is dead and Schr¨odinger’s cat is not dead. I It is not the case that the derivative of sin x is cos x. Truth table: Truth table: p q p ∧ q p ¬p 0 0 0 0 1 0 1 0 1 0 1 0 0 1 1 1 Logical Or Exclusive Or The logical disjunction (or logical or) is true if one or both of the The exclusive or of two propositions is true when exactly one of its propositions are true. propositions is true and the other one is false. Example (Logical Connective: Or) Example (Logical Connective: Exclusive Or) The circuit is either is on or off. I It is raining or it is the second day of lecture. I √ Let ab < 0, then either a < 0 or b < 0 but not both. I (2 + 2 = 5) ∨ ( 2 < 2) I 1 You may have cake or ice cream, but not both. I You may have cake or ice cream. I Truth table: Truth table: p q p ∧ q p ∨ q 0 0 0 0 p q p ⊕ q 0 1 0 1 0 0 0 1 0 0 1 0 1 1 1 1 1 1 1 0 1 1 1 0 1Can I have both? Implications I Implications II Definition The implication p → q can be equivalently read as Let p and q be propositions. The implication I if p then q p → q I p implies q if p, q is the proposition that is false when p is true and q is false and I true otherwise. I p only if q I q if p Here, p is called the “hypothesis” (or “antecedent” or “premise”) I q when p and q is called the “conclusion” or “consequence”. I q whenever p Truth table: p q p → q I p is a sufficient condition for q (p is sufficient for q) 0 0 1 I q is a necessary condition for p (q is necessary for p) 0 1 1 I q follows from p 1 0 0 1 1 1 Examples Exercise Which of the following implications is true? Example I If −1 is a positive number, then 2 + 2 = 5. true: the hypothesis is obviously false, thus no matter what I If you buy your air ticket in advance, it is cheaper. the conclusion, the implication holds. If x is a real number, then x2 ≥ 0. I I If −1 is a positive number, then 2 + 2 = 4. I If it rains, the grass gets wet. true: for the same reason as above I If the sprinklers operate, the grass gets wet. I If sin x = 0 then x = 0. false: x can be any multiple of π; i.e. if we let x = 2π then I If 2 + 2 = 5 then all unicorns are pink. clearly sin x = 0, but x 6= 0. The implication “if sin x = 0 then x = kπ for some integer k” is true. Biconditional Examples Definition p ↔ q can be equivalently read as The biconditional p ↔ q I p if and only if q p is necessary and sufficient for q is the proposition that is true when p and q have the same truth I values. It is false otherwise. I if p then q, and conversely I p iff q (Note typo in textbook, page 9, line 3.) Note that it is equivalent to (p → q) ∧ (q → p) Truth table: Example 2 p q p → q q → p p ↔ q I x > 0 if and only if x is positive. 0 0 1 1 1 I The alarm goes off iff a burglar breaks in. 0 1 1 0 0 I You may have pudding if and only if you eat your meat. 1 0 0 1 0 1 1 1 1 1 Exercise Converse, Contrapositive, Inverse Which of the following biconditionals is true? 2 2 I x + y = 0 if and only if x = 0 and y = 0 Consider the proposition p → q: true: both implications hold. √ I 2 + 2 = 4 if and only if 2 < 2 I Its converse is the proposistion q → p. true: for the same reason above. I Its inverse is the proposistion ¬p → ¬q. 2 I x ≥ 0 if and only if x ≥ 0. I Its contrapositive is the proposistion ¬q → ¬p. false: The converse holds. That is, “if x ≥ 0 then x2 ≥ 0”. However, the implication is false; consider x = −1. Then the hypothesis is true, (−1)2 = 12 ≥ 0 but the conclusion fails. Truth Tables I Constructing Truth Tables Truth Tables are used to show the relationship between the truth values of individual propositions and the compound propositions Construct the Truth Table for the following compound proposition. based on them. ((p ∧ q) ∨ ¬q) p q p ∧ q p ∨ q p ⊕ q p → q p ↔ q 0 0 0 0 0 1 1 p q p ∧ q ¬q ((p ∧ q) ∨ ¬q) 0 1 0 1 1 1 0 0 0 0 1 1 1 0 0 1 1 0 0 0 1 0 0 0 1 1 1 1 0 1 1 1 0 0 1 1 Table: Truth Table for Logical Conjunction, Disjunction, Exclusive Or, 1 1 1 0 1 and Implication Precedence of Logical Operators Usefulness of Logic Just as in arithmetic, an ordering must be imposed on the use of logical operators in compound propositions. Logic is more precise than natural language: Of course, parentheses can be used to make operators disambiguous: I You may have cake or ice cream. Can I have both? ¬p ∨ q ∧ ¬r ≡ (¬p) ∨ q ∧ (¬r) I If you buy your air ticket in advance, it is cheaper. Are there or not cheap last-minute tickets? But to avoid using unnecessary parentheses, we define the following precedences: For this reason, logic is used for hardware and software specification. 1. (¬) Negation 2. (∧) Conjunction Given a set of logic statements, one can decide whether or not they are satisfiable (i.e., consistent), although this is a costly process... 3. (∨) Disjunction 4. (→) Implication 5. (↔) Biconditional Bitwise Operations Logic in Theorerical Computer Science Computers represent information as bits (binary digits). SAT A bit string is a sequence of bits, the length of the string is the number of bits in the string. Logical connectives can be applied to bit strings (of equal length). What is SAT? SAT is the problem of determining whether or not To do this, we simply apply the connective rules to each bit of the a sentence in propositional logic (PL) is satisfiable. Characterizing string: SAT as an NP-complete problem is at the foundation of Theoretical Computer Science. Example Defining SAT I Given: a PL sentence. 0110 1010 1101 Question: Determine whether it is satisfiable or not. 0101 0010 1111 I 0111 1010 1111 bitwise Or What is a PL sentence? What does satisfiable mean? 0100 0010 1101 bitwise And 0011 1000 0010 bitwise Xor A Boolean variable is a variable that can have value 0 or 1. Logic in Theorerical Computer Science Logic in Programming A sentence in PL Programming Example I Say you need to define a conditional statement as follows: I A sentence in PL is a conjunction of clauses “Increment x if all of the following conditions hold: x > 0, x < 10 I A clause is a disjunction of literals and x = 10.” I A literal is a term or its negation You may try: A term is a (Boolean) variable (or proposition) I if(0<x<10 OR x=10) x++; Example: (a ∨ b ∨ ¬c ∨ ¬d) ∧ (¬b ∨ c) ∧ (¬a ∨ c ∨ d) But is not valid in C++ or Java.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    7 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us