Unit 3: Logic Gates and Recurrence Relations
Digital logic and recurrence relations are the two computational cores of discrete structures: the first turns Boolean algebra into physical circuitry, the second turns self-reference into closed-form counting. Both rest on a small set of primitive rules applied repeatedly.
- Boolean domain: every variable takes one of two values, written
0/1,F/T, orLOW/HIGH; there are no intermediate states. - Three basic operations: AND (
·), OR (+) and NOT ('or overbar) generate all Boolean functions and hence all gates. - Functional completeness: the set {AND, OR, NOT} is complete; so is {NAND} alone and {NOR} alone, which is why real hardware is built mostly from NAND/NOR.
- Recursive definition: a rule that defines an object in terms of smaller instances of itself, plus base case(s) that terminate the descent.
- Sequence convention:
aₙdenotes the nth term;n ≥ 0unless stated, and initial conditions fix the sequence uniquely.
II. Logic Gates — Boolean Functions Realised as Hardware
A logic gate is a physical device implementing one Boolean operation, mapping one or more binary inputs to a single binary output defined by a truth table.
A. Introduction to Logic Gates
The seven standard gates cover every one- and two-input Boolean primitive.
- AND: output 1 only when all inputs are 1:
Y = A·B. Truth table row 11→1, else 0. - OR: output 1 when any input is 1:
Y = A + B. Only 00→0. - NOT (inverter): single input,
Y = A'; 0→1, 1→0. - NAND: AND followed by NOT,
Y = (A·B)'; output 0 only for 11. Universal gate. - NOR: OR followed by NOT,
Y = (A+B)'; output 1 only for 00. Universal gate. - XOR (exclusive-OR):
Y = A⊕B = A'B + AB'; output 1 when inputs differ. - XNOR (equivalence):
Y = (A⊕B)' = AB + A'B'; output 1 when inputs match.
Standard two-input truth table:
A B | AND OR NAND NOR XOR XNOR
0 0 | 0 0 1 1 0 1
0 1 | 0 1 1 0 1 0
1 0 | 0 1 1 0 1 0
1 1 | 1 1 0 0 0 1B. Combination of Gates
Complex Boolean functions are built by cascading gates so that outputs feed subsequent inputs.
- Expression-to-circuit mapping: each operator becomes a gate; nesting order follows operator precedence NOT > AND > OR.
- Worked build of
Y = A·B + C': invertCwith a NOT gate, feedA,Bto an AND gate, feed both results to an OR gate. Two levels of logic, three gates. - Universality demonstrated with NAND:
- NOT from NAND: tie both inputs together,
(A·A)' = A'. - AND from NAND: NAND then invert,
((A·B)')' = A·B. - OR from NAND: invert both inputs then NAND,
(A'·B')' = A + B(De Morgan).
- NOT from NAND: tie both inputs together,
- XOR as a combination:
A⊕B = (A·(A·B)')·((A·B)'·B)implemented with four NAND gates — shows a "derived" gate is just a fixed cluster of primitives. - Boolean simplification first: apply laws such as
A + A'B = A + BorA·A' = 0before wiring, since fewer literals mean fewer gates and shorter propagation delay.
C. Implementation of Logic Gates to the Switching Circuits
Logic gates are the algebraic abstraction of switching networks, where a switch is a Boolean variable — closed (1) conducts, open (0) blocks.
- Series connection = AND: current flows only if switch
Aand switchBare both closed, so conduction= A·B. Two switches in a single line. - Parallel connection = OR: current flows if switch
Aor switchBis closed, so conduction= A + B. Two switches on separate branches.
- Complementary switch: a normally-closed switch conducts when its variable is 0, realising
A'. - Series–parallel translation: any Boolean expression in sum-of-products form maps to parallel branches (the
+) of series switches (the·).- Example:
Y = A·B + C→ one branch withAin series withB, wired in parallel with a lone switchC.
- Example:
- Bridge/relay circuits: electromechanical relays historically implemented these networks; Shannon's 1938 thesis established the exact equivalence between switching circuits and Boolean algebra.
- Design goal: minimise switches by algebraic reduction, e.g.
A·B + A·B' = A·(B + B') = Acollapses two series pairs into a single switch.
III. Recurrence Relations — Sequences Defined by Their Own Past
A recurrence relation defines each term of a sequence as a function of one or more preceding terms, together with base cases that anchor the definition.
A. Introduction to Recursion
Recursion expresses a problem's solution in terms of smaller instances of the same problem.
- Two mandatory parts: a base case that halts the descent, and a recursive case that reduces the problem toward the base.
- Factorial:
n! = n·(n−1)!with base0! = 1; computing4!unwinds4·3·2·1·1. - Fibonacci definition:
F(n) = F(n−1) + F(n−2), baseF(0)=0, F(1)=1. - Recursion vs iteration: recursion mirrors the mathematical definition and uses the call stack; iteration reuses variables and avoids stack growth but obscures the structure.
- Failure mode: omitting or never reaching the base case causes infinite recursion (stack overflow).
B. Recurrence Relation
A recurrence relation is the formal equation stating the dependence of aₙ on earlier terms.
- General form:
aₙ = f(aₙ₋₁, aₙ₋₂, …, aₙ₋ₖ)forn ≥ k, withkinitial conditions supplied. - Order: the difference between the highest and lowest indices;
aₙ = aₙ₋₁ + aₙ₋₂is order 2. - Degree: the highest power of any term;
aₙ = aₙ₋₁²has degree 2 (non-linear). - Linear: each
aₙ₋ᵢappears to the first power and is not multiplied by another term. - Homogeneous: every term contains some
aₙ₋ᵢ; no standalone function ofn. If a term like2ⁿappears alone, the relation is non-homogeneous. - Modelling example: compound interest
Pₙ = 1.05·Pₙ₋₁(order 1, linear, homogeneous); Tower of Hanoi movesHₙ = 2Hₙ₋₁ + 1(order 1, linear, non-homogeneous).
C. Solving Recurrence Relation
Solving means finding a closed-form (explicit) expression for aₙ that removes all self-reference.
- Iteration / substitution (back-substitution): repeatedly expand the recurrence until a pattern emerges, then generalise.
- Worked example
aₙ = aₙ₋₁ + 3,a₀ = 2:
TEXTa₁ = a₀ + 3 a₂ = a₀ + 3·2 aₙ = a₀ + 3n = 2 + 3n - Verified:
a₃ = 2 + 9 = 11, matching direct computation5,8,11.
- Worked example
- Forward substitution: start from base and build upward when the pattern is easier to spot ascending.
- Characteristic-root method: the systematic technique for linear homogeneous relations, developed in the next subsection.
- Generating functions: encode the sequence as coefficients of a power series and solve algebraically — a general but heavier tool.
D. Linear Homogeneous Recurrence Relation with Constant Coefficients and Their Solution
This class admits a complete, mechanical solution via the characteristic equation.
- Standard form:
aₙ = c₁aₙ₋₁ + c₂aₙ₋₂ + … + cₖaₙ₋ₖ, where eachcᵢis a constant andcₖ ≠ 0; orderk. - Characteristic equation: substitute the trial solution
aₙ = rⁿto obtain
TEXTrᵏ − c₁rᵏ⁻¹ − c₂rᵏ⁻² − … − cₖ = 0 - General solution by root type:
- Distinct roots
r₁,…,rₖ:aₙ = α₁r₁ⁿ + α₂r₂ⁿ + … + αₖrₖⁿ, constantsαᵢfixed by initial conditions. - Repeated root
rof multiplicitym: that root contributes(α₀ + α₁n + … + α_{m−1}n^{m−1})rⁿ, an extra factor ofnper repetition.
- Distinct roots
- Worked example (Fibonacci):
aₙ = aₙ₋₁ + aₙ₋₂,a₀=0, a₁=1.- Characteristic equation
r² − r − 1 = 0, rootsr = (1 ± √5)/2. - General solution
aₙ = α₁((1+√5)/2)ⁿ + α₂((1−√5)/2)ⁿ. - Applying
a₀=0, a₁=1givesα₁ = 1/√5,α₂ = −1/√5, yielding Binet's formula
TEXTaₙ = (1/√5)[((1+√5)/2)ⁿ − ((1−√5)/2)ⁿ]
- Characteristic equation
- Repeated-root example:
aₙ = 4aₙ₋₁ − 4aₙ₋₂givesr² − 4r + 4 = 0, rootr = 2twice, soaₙ = (α₀ + α₁n)2ⁿ. - Symbols defined:
rⁿis the geometric trial term;αᵢare arbitrary constants; multiplicitymcounts how often a root repeats;kinitial conditions are always exactly enough to determine thekconstants.
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →