Docsity

Introduction to Propositional and Predicate Logic, Summaries of Discrete Mathematics

Partial preview of the text

Download Introduction to Propositional and Predicate Logic and more Summaries Discrete Mathematics in PDF only on Docsity!

Table of Contents

1 Propositional Logic

▶ Propositional Logic

▶ Predicate Logic and Sets

Course Introduction

1 Propositional Logic

  • Why Discrete Math? Foundation for algorithms, data structures, cryptography, and networks.
  • Relevance to CS : Logic drives programming, circuit design, and database queries.
  • Real World Context : Model decision-making in MTN Mobile Money or Ghana’s voter system.

Logical Connectives

1 Propositional Logic

  • AND (∧): True if both propositions are true.
  • OR (∨): True if at least one proposition is true.
  • NOT (¬): Negates the truth value.
  • IMPLIES (→): True unless true premise leads to false conclusion.
  • BICONDITIONAL (↔): True if both have same truth value.

Example: Mobile Money System

1 Propositional Logic

Example

Let p : “PIN is correct,” q : “Balance is sufficient.”

  • Model: p ∧ q → Transfer succeeds.
  • English: “If the PIN is correct and the balance is sufficient, then the transfer succeeds.”

Truth Tables: NOT and IMPLIES

1 Propositional Logic

p ¬ p q p → q T F T T T F F F F T T T F T F T Table 2: Truth table for NOT and IMPLIES

Truth Tables: BICONDITIONAL

1 Propositional Logic

p q p ↔ q T T T T F F F T F F F T

Table 3: Truth table for BICONDITIONAL

Logical Equivalences

1 Propositional Logic

Theorem (De Morgan’s Laws)

  • ¬( p ∧ q ) ≡ ¬ p ∨ ¬ q
  • ¬( p ∨ q ) ≡ ¬ p ∧ ¬ q

Example

In Ghana’s voting system: “Not (valid ID AND registered)” ≡ “Not valid ID OR not registered.”

Proof: De Morgan’s First Law

1 Propositional Logic

Proof.

Show ¬( p ∧ q ) ≡ ¬ p ∨ ¬ q using a truth table.

p q ¬( p ∧ q ) ¬ p ∨ ¬ q Equal? T T F F T T F T T T F T T T T F F T T T

Solved Example 2: Programming Logic

1 Propositional Logic

Example

Model: “If user is registered OR has guest access, allow entry.”

  • Let p : “User is registered,” q : “Has guest access.”
  • Logic: p ∨ q.

def allow_entry ( registered , guest_access ) : return registered or guest_access

Exercise 1: Truth Table

1 Propositional Logic

Problem

Construct the truth table for ¬( p → q ).

Exercise 3: Real World Context

1 Propositional Logic

Problem

Model: “If payment is made AND item is in stock, then order is processed” for a Jumia Ghana order. Write the logical expression and construct its truth table.

Exercise 4: Coding Logic

1 Propositional Logic

Problem

Write a Python function for: “Allow transaction if PIN is correct OR user is verified by SMS.”

Predicate Logic: Basics

2 Predicate Logic and Sets

Definition

A predicate P ( x ) is a statement about variable x , e.g., P ( x ): “ x is a KNUST student.”

  • Quantifiers : ∀ (all), ∃ (some).
  • Example : ∀ x ( P ( x ) → has ID card).

Solved Example: Predicate Logic

2 Predicate Logic and Sets

Example

Translate: “Some KNUST students use MTN Mobile Money.” Let P ( x ): “ x is a KNUST student,” Q ( x ): “ x uses MTN Mobile Money.” Answer: ∃ x ( P ( x ) ∧ Q ( x )).