Software Development  ·  Level 5
Discrete Mathematical Concepts
Chapter 4: Apply logic gates
📚 3 Topics
What you will be able to do

By the end of this chapter, you will be able to:

  • accurately identify different logic gates using Digital Electronics principles
  • clearly illustrate logic circuits following the correct standard procedures
  • simplify logic circuits correctly using standard methods

Mastering these skills will help you design and troubleshoot digital systems confidently, a key ability in modern electronics and technology fields.

Logic gates are fundamental building blocks of digital circuits used in various Kenyan industries such as banking, healthcare, and county government offices to automate decision-making and data processing. Understanding the operation and application of different types of logic gates enables professionals to design and analyze systems that depend on binary inputs and produce specific outputs. This chapter covers the main types of logic gates with practical examples relevant across multiple sectors to enhance problem-solving skills in discrete mathematical contexts.

4.1 Types of Logic Gates

Logic gates perform basic logical functions on one or more binary inputs producing a single output. These gates are essential in digital electronics and computing, where signals are represented in binary form as 0 (low) or 1 (high). Each gate has a unique truth table and symbolic representation used in circuit design and analysis.

4.1.1 AND Gate

The AND gate outputs 1 only when all its inputs are 1; otherwise, it outputs 0. It is used in scenarios where all conditions must be met to trigger an action, such as verifying multiple approval signals in a bank’s security system.

The AND gate operation is represented by the formula:

$$ Y = A \times B $$

where \(A\) and \(B\) are inputs and \(Y\) is the output.

Worked Examples

Example 1: A county hospital’s access control system uses an AND gate to unlock a door only if both a staff ID card and a PIN code are verified. If the staff ID is valid (1) and the PIN is correct (1), what is the output?

Given: \(A = 1\), \(B = 1\)

$$ Y = A \times B $$$$ Y = 1 \times 1 $$$$ Y = 1 $$

Answer: 1 (Door unlocks)

Example 2: A retail business uses an AND gate to activate a discount only if the customer has a membership card (input \(A\)) and the purchase amount exceeds Ksh 5,000 (input \(B\)). If \(A=1\) and \(B=0\), what is the output?

Given: \(A=1\), \(B=0\)

$$ Y = A \times B $$$$ Y = 1 \times 0 $$$$ Y = 0 $$

Answer: 0 (No discount applied)

Example 3: A university’s examination system requires both submission of assignments (input \(A\)) and attendance of lectures (input \(B\)) to qualify for final exams. If \(A=0\) and \(B=0\), determine the output.

Given: \(A=0\), \(B=0\)

$$ Y = A \times B $$$$ Y = 0 \times 0 $$$$ Y = 0 $$

Answer: 0 (Not qualified for exams)

4.1.2 OR Gate

The OR gate outputs 1 if at least one of its inputs is 1; it outputs 0 only if all inputs are 0. This gate is useful in systems where any one condition can trigger a response, such as alert systems in county government offices.

The OR gate operation is expressed as:

$$ Y = A + B $$

where \(+\) denotes logical OR.

Worked Examples

Example 1: A SACCO’s loan approval system uses an OR gate to approve loans if either a guarantor is present (input \(A\)) or the applicant has a good credit score (input \(B\)). If \(A=0\) and \(B=1\), find the output.

Given: \(A=0\), \(B=1\)

$$ Y = A + B $$$$ Y = 0 + 1 $$$$ Y = 1 $$

Answer: 1 (Loan approved)

Example 2: A cooperative’s irrigation system activates if either the soil moisture sensor (input \(A\)) or the rain forecast sensor (input \(B\)) detects dryness. If both sensors detect dryness (\(A=1\), \(B=1\)), determine the output.

Given: \(A=1\), \(B=1\)

$$ Y = A + B $$$$ Y = 1 + 1 $$$$ Y = 1 $$

Answer: 1 (Irrigation activated)

Example 3: A hotel’s emergency lighting turns on if either the main power fails (input \(A\)) or the backup generator fails (input \(B\)). If \(A=0\) and \(B=0\), what is the output?

Given: \(A=0\), \(B=0\)

$$ Y = A + B $$$$ Y = 0 + 0 $$$$ Y = 0 $$

Answer: 0 (Emergency lighting off)

4.1.3 NOT Gate

The NOT gate, or inverter, outputs the opposite of the input; if input is 1, output is 0, and vice versa. It is used to reverse signals, for example, to indicate a system is off when a sensor reads on.

The NOT gate operation is:

$$ Y = \overline{A} $$

where \(\overline{A}\) is the complement of input \(A\).

Worked Examples

Example 1: A retail shop’s alarm system activates only if the door sensor signal is 0 (door closed). If the door sensor input is 1 (door open), what is the output of the NOT gate connected to it?

Given: \(A=1\)

$$ Y = \overline{A} $$$$ Y = \overline{1} $$$$ Y = 0 $$

Answer: 0 (Alarm not activated)

Example 2: A county government office’s lighting system uses a NOT gate to switch lights off when the daylight sensor input is 1 (daylight present). If the daylight sensor reads 0 (night), find the output.

Given: \(A=0\)

$$ Y = \overline{A} $$$$ Y = \overline{0} $$$$ Y = 1 $$

Answer: 1 (Lights on)

Example 3: A hospital’s equipment safety indicator uses a NOT gate to show "Safe" when the hazard sensor input is 0 (no hazard). If the sensor input is 1 (hazard detected), determine the output.

Given: \(A=1\)

$$ Y = \overline{A} $$$$ Y = \overline{1} $$$$ Y = 0 $$

Answer: 0 (Not safe)

4.1.4 NAND Gate

The NAND gate outputs 0 only when all its inputs are 1; otherwise, it outputs 1. It is widely used in digital circuits because any logical operation can be constructed using NAND gates alone.

The NAND gate operation is:

$$ Y = \overline{A \times B} $$

Worked Examples

Example 1: A university’s exam system uses a NAND gate to deny access only if both the registration form (input \(A\)) and fee payment (input \(B\)) are complete. If \(A=1\) and \(B=1\), find the output.

Given: \(A=1\), \(B=1\)

$$ Y = \overline{A \times B} $$$$ Y = \overline{1 \times 1} $$$$ Y = \overline{1} $$$$ Y = 0 $$

Answer: 0 (Access denied)

Example 2: A bank’s fraud detection system triggers if not both alerts (input \(A\) and \(B\)) are active. If \(A=1\) and \(B=0\), determine the output.

Given: \(A=1\), \(B=0\)

$$ Y = \overline{A \times B} $$$$ Y = \overline{1 \times 0} $$$$ Y = \overline{0} $$$$ Y = 1 $$

Answer: 1 (No fraud trigger)

Example 3: A cooperative’s irrigation system uses a NAND gate to stop irrigation only when both moisture sensors detect sufficient moisture (\(A=1\), \(B=1\)). If \(A=0\) and \(B=1\), find the output.

Given: \(A=0\), \(B=1\)

$$ Y = \overline{A \times B} $$$$ Y = \overline{0 \times 1} $$$$ Y = \overline{0} $$$$ Y = 1 $$

Answer: 1 (Irrigation continues)

4.1.5 NOR Gate

The NOR gate outputs 1 only when all inputs are 0; otherwise, it outputs 0. It is useful in systems where action is taken only when no conditions are met.

The NOR gate operation is:

$$ Y = \overline{A + B} $$

Worked Examples

Example 1: A hotel’s security system activates an alarm only if neither the motion sensor (input \(A\)) nor the door sensor (input \(B\)) detects movement. If \(A=0\), \(B=0\), what is the output?

Given: \(A=0\), \(B=0\)

$$ Y = \overline{A + B} $$$$ Y = \overline{0 + 0} $$$$ Y = \overline{0} $$$$ Y = 1 $$

Answer: 1 (Alarm activated)

Example 2: A retail shop turns off the lights when neither the customer sensor (input \(A\)) nor the staff sensor (input \(B\)) detects presence. If \(A=1\), \(B=0\), find the output.

Given: \(A=1\), \(B=0\)

$$ Y = \overline{A + B} $$$$ Y = \overline{1 + 0} $$$$ Y = \overline{1} $$$$ Y = 0 $$

Answer: 0 (Lights remain on)

Example 3: A county government office uses a NOR gate to signal “No requests” when neither request button (input \(A\)) nor call button (input \(B\)) is pressed. If \(A=0\), \(B=1\), what is the output?

Given: \(A=0\), \(B=1\)

$$ Y = \overline{A + B} $$$$ Y = \overline{0 + 1} $$$$ Y = \overline{1} $$$$ Y = 0 $$

Answer: 0 (Requests present)

4.1.6 XOR Gate

The XOR (exclusive OR) gate outputs 1 only if exactly one input is 1; if both inputs are the same, output is 0. It is used in parity checks and error detection, common in ICT systems.

The XOR operation is:

$$ Y = A \oplus B = (A \times \overline{B}) + (\overline{A} \times B) $$

Worked Examples

Example 1: A bank’s authentication system uses XOR to detect mismatched PIN entries. If input \(A=1\) (correct PIN) and \(B=0\) (entered PIN), find the output.

Given: \(A=1\), \(B=0\)

$$ Y = (A \times \overline{B}) + (\overline{A} \times B) $$$$ Y = (1 \times \overline{0}) + (\overline{1} \times 0) $$$$ Y = (1 \times 1) + (0 \times 0) $$$$ Y = 1 + 0 $$$$ Y = 1 $$

Answer: 1 (Mismatch detected)

Example 2: A cooperative’s voting system uses XOR to check if two votes differ. If \(A=1\) and \(B=1\), what is the output?

Given: \(A=1\), \(B=1\)

$$ Y = (A \times \overline{B}) + (\overline{A} \times B) $$$$ Y = (1 \times \overline{1}) + (\overline{1} \times 1) $$$$ Y = (1 \times 0) + (0 \times 1) $$$$ Y = 0 + 0 $$$$ Y = 0 $$

Answer: 0 (Votes agree)

Example 3: An ICT system uses XOR for error detection in data transmission. If \(A=0\) and \(B=1\), compute the output.

Given: \(A=0\), \(B=1\)

$$ Y = (A \times \overline{B}) + (\overline{A} \times B) $$$$ Y = (0 \times \overline{1}) + (\overline{0} \times 1) $$$$ Y = (0 \times 0) + (1 \times 1) $$$$ Y = 0 + 1 $$$$ Y = 1 $$

Answer: 1 (Error detected)

4.1.7 XNOR Gate

The XNOR gate outputs 1 when inputs are equal and 0 when inputs differ; it is the complement of XOR. It is used in equality checks, such as verifying matching data entries in databases.

The XNOR operation is:

$$ Y = \overline{A \oplus B} = (A \times B) + (\overline{A} \times \overline{B}) $$

Worked Examples

Example 1: A SACCO’s member validation system uses XNOR to confirm matching ID and database record. If \(A=1\) and \(B=1\), determine the output.

Given: \(A=1\), \(B=1\)

$$ Y = (A \times B) + (\overline{A} \times \overline{B}) $$$$ Y = (1 \times 1) + (\overline{1} \times \overline{1}) $$$$ Y = 1 + (0 \times 0) $$$$ Y = 1 + 0 $$$$ Y = 1 $$

Answer: 1 (Match confirmed)

Example 2: A hospital’s patient monitoring system uses XNOR to check if sensor readings match expected values. If \(A=0\) and \(B=1\), compute the output.

Given: \(A=0\), \(B=1\)

$$ Y = (A \times B) + (\overline{A} \times \overline{B}) $$$$ Y = (0 \times 1) + (\overline{0} \times \overline{1}) $$$$ Y = 0 + (1 \times 0) $$$$ Y = 0 + 0 $$$$ Y = 0 $$

Answer: 0 (Mismatch detected)

Example 3: A county government office uses XNOR to verify consistency between two data entry points. If \(A=0\) and \(B=0\), calculate the output.

Given: \(A=0\), \(B=0\)

$$ Y = (A \times B) + (\overline{A} \times \overline{B}) $$$$ Y = (0 \times 0) + (1 \times 1) $$$$ Y = 0 + 1 $$$$ Y = 1 $$

Answer: 1 (Data entries consistent)

Practice Questions

  1. A county hospital’s emergency system activates only when both fire alarm (input \(A\)) and smoke sensor (input \(B\)) are triggered. Calculate the AND gate output for \(A=1\), \(B=0\). (3 marks)

  2. A retail business uses an OR gate to turn on a promotional screen if either the motion sensor (input \(A\)) or the customer button (input \(B\)) is activated. Find the output when \(A=0\), \(B=1\). (3 marks)

  3. A bank’s security system uses a NOT gate to invert the door closed signal (input \(A\)). If \(A=0\), what is the output? (3 marks)

  4. A university’s exam eligibility system uses a NAND gate for inputs: registered (input \(A\)) and fees paid (input \(B\)). Calculate the output for \(A=1\), \(B=1\). (3 marks)

  5. A hotel lighting system uses a NOR gate for presence sensors (inputs \(A\) and \(B\)). Compute the output if \(A=0\), \(B=0\). (3 marks)

  6. An ICT system uses XOR to detect errors between sent (input \(A\)) and received bits (input \(B\)). Find the output for \(A=1\), \(B=0\). (3 marks)

  7. A SACCO database uses XNOR to verify matching member data inputs \(A\) and \(B\). Determine the output when \(A=0\), \(B=0\). (3 marks)

The rest of this chapter
🔒

Create a free account to open more of this chapter.

Free: practical guides, quick cards, workplace scenarios and more.

Create a free account
🔒4.2 Logic expressions

Logic expressions are fundamental in representing logical operations in digital systems. They describe the relationship between input and output variables using logical operators such as AND, OR, and NOT. In Kenyan institutions like county referral hospitals o…

🔒4.3 Simplifying logic expressions

Simplifying logic expressions is essential in designing efficient digital systems used in various sectors such as banking, healthcare, and county administration. A simplified Boolean expression reduces the number of logic gates needed, which in turn lowers cos…

Chapter Summary

This chapter introduced the various types of logic gates including AND, OR, NOT, NAND, NOR, XOR, and XNOR, explaining their individual functions in digital circuits. It then covered how logic expressions are represented using circuit diagrams and truth tables to visualize their operation. The chapter further explored methods to simplify logic expressions by applying De Morgan's theorems and the fundamental laws of Boolean algebra such as commutative, associative, distributive, identity, null, and complement laws. Techniques for simplifying Boolean expressions were demonstrated, highlighting their importance in optimizing digital circuits. The practical applications of Boolean algebra were discussed to emphasize its role in designing efficient logical systems. Finally, the chapter introduced Karnaugh maps as a graphical tool to simplify complex Boolean expressions systematically, enhancing the understanding and analysis of logical functions.

Self-Assessment

🔒 PDFDownload this self-assessment, with answers

Written Assessment

  1. Given two inputs \(A = 1\) and \(B = 0\), find the output of the AND gate. (1 mark)

  2. For inputs \(A = 0\) and \(B = 1\), calculate the output of the OR gate. (1 mark)

🔒18 more in this section.

Chapter Examination Questions

🔒 PDFDownload these examination questions, with model answers

SECTION A (40 Marks) - Answer ALL Questions

  1. A SACCO uses an AND gate to control access to its vault. The inputs are a valid PIN code (1 for valid, 0 for invalid) and a fingerprint scan (1 for match, 0 for no match). Construct the truth table for the AND gate used. (4 marks)
  2. At a county hospital, the emergency alarm system uses an OR gate with inputs from fire detection and gas leak sensors. Write the logic expression for the OR gate and draw its circuit symbol. (4 marks)
🔒18 more in this section.
Flashcards 21 cards Study deck ▾
Question
1

↻ Tap card to reveal answer
🔒

19 more in this section.

Create a free account
Test Yourself 15 questions Start quiz ▾
0%
0 / 2
🔒

13 more in this section.

Create a free account
Am I competent?

At the start of this chapter we promised you would be able to:

  • accurately identify different logic gates using Digital Electronics principles
  • clearly illustrate logic circuits following the correct standard procedures
  • simplify logic circuits correctly using standard methods

Tick each one you can genuinely do.

So, are you there yet?

You're competent when you can confidently do 50% or more of what this chapter promised.

Sign in to record how you're doing.