Docsity

LECTURE 1 Discrete Structures, Essays (university) of Computer Science

Partial preview of the text

Download LECTURE 1 Discrete Structures and more Essays (university) Computer Science in PDF only on Docsity!

CSC102 - Discrete Structures By Mahwish Waqas

Department Of Computer Science, CUI

Lahore Campus

Lecture Outline

• Propositional Logic

  • Proposition and Propositional Variables
  • Compound Proposition
  • Logical Operators
  • Truth Table of a compound proposition 9/20/2020 CSC102 - Discrete Structures (^) 2

Propositional Logic

  • Letter are used to denote propositional variables, to symbolically represent propositions. - Letters used for this purpose are p, q, r, s,……… - A propositional can have one of two values: true (T) or false (F).
  • Example
    • p = “Islamabad is the capital of Pakistan”
    • q = “17 is divisible by 3” 9/20/2020 CSC102 - Discrete Structures (^) 4

Propositional Logic

  • The area of logic that deals with propositions is called the Propositional Calculus or Propositional Logic.
  • Compound Propositions are constructed by combining one or more propositions using logical operators (connectives).
  • Examples
    • “3 + 2 = 5” and “Lahore is a city in Pakistan”
    • “The grass is green” or “ It is hot today” 9/20/2020 CSC102 - Discrete Structures (^) 5

Logical Operators (Logical connectives)

  • Negation
    • This just turns a false proposition to true and the opposite for a true proposition.
    • Symbol: ¬
    • Let p is a proposition. The statement “It is not the case that p.” is another proposition, called the negation of p.
    • The negation of p is written ¬ p and read as “not p”. 9/20/2020 CSC102 - Discrete Structures (^) 7

Logical Operator - Negation

  • Logical operators are defined by truth table – table which give the output of the operator in the right-most column.
  • Here is the truth table for negation: CSC102 - Discrete Structures (^) 8 P^ ¬ P p ¬ p T F F T 9/20/

Logical Operator - Conjunction

  • Conjunction is a binary operator in that it operates on two propositions when creating compound proposition. On the other hand, negation is a unary operator.
  • Conjunction corresponds to English “and.”
  • Symbol: ∧
  • Let p and q be propositions. The conjunction of p and q, denoted by p ∧ q, is the proposition “p and q”. The conjunction p ∧ q is true when both p and q are true. If one of these is false, than the compound statement is false as well. 9/20/2020 CSC102 - Discrete Structures (^) 10

Logical Operator - Conjunction

  • Truth Table CSC102 - Discrete Structures (^) 11 p q p ∧ q T T T T F F F T F F F F 9/20/

Logical Operator - Conjunction

  • Hamza’s PC has more than 16 GB free hard disk space, and the processor in Hamza’s PC runs faster than 1 GHz.
  • It is cold but sunny. 9/20/2020 CSC102 - Discrete Structures (^) 13

Logical Operator - Disjunction

  • Disjunction is also a binary operator.
  • Disjunction corresponds to English “or.”
  • Symbol: ∨
  • Let p and q be propositions. The disjunction of p and q, denoted by p ∨ q, is the proposition “p or q”. The conjunction p ∨ q is false when both p and q are false and is true otherwise. 9/20/2020 CSC102 - Discrete Structures (^) 14

Logical Operator - Disjunction

  • Example Let p = “Today is Friday.” and q = “It is raining today.” p ∨ q = “Today is Friday or it is raining today.” 9/20/2020 CSC102 - Discrete Structures (^) 16

Example

Let p = “it is sunny”, q = “it is raining”

  • It is sunny and raining. p ∧ q
  • It is not sunny but raining. ¬p ∧ q
  • It is neither sunny nor raining. ¬p ∧ ¬q 9/20/2020 CSC102 - Discrete Structures (^) 17

Logical Operator – Exclusive Or

  • Example Let p = “Students who have taken calculus can take this class.” and q = “Students who have taken computer science can take this class.” p ∨ q = “Students who have taken calculus or computer science can take this class.” p ⊕ q = “Students who have taken calculus or computer science, but not both, can take this class.” 9/20/2020 CSC102 - Discrete Structures (^) 19

Exclusive or Versus Inclusive or (Disjunction)

  • Coffee or tea comes with dinner.
  • A password must have at least three digits or be at least five characters long.
  • Lunch includes soup or salad.
  • Experience with C++ or Java is required. CSC102 - Discrete Structures (^) 20 Inclusive or Exclusive or Inclusive or Exclusive or 9/20/