Mathematics for Computer Science

Chapter 6
Boolean Algebra and Algebraic Structures

Bachelors Program in Computer Science Engineering
Mathematics for Computer Science   •   Bachelor

Boolean Algebra and Algebraic Structures

Introduction

Boolean algebra and abstract algebra provide a common mathematical language for computer systems. Boolean operations model logic gates, predicates and set operations. Lattices formalize information ordering, program analysis and fixed-point semantics. Groups describe reversible transformations and modular operations, while rings and fields support polynomial computation, error-correcting codes and cryptography.

These structures are not merely collections with operations. Their axioms determine which transformations, algorithms and proofs are valid. For example, division is always possible by a nonzero element in a field, but not in an arbitrary ring. Likewise, a Boolean expression may be algebraically equivalent to a simpler expression even though the corresponding physical circuit still requires timing analysis.

Throughout this chapter, a ring is assumed to have a multiplicative identity 1R, unless explicitly stated otherwise. All mathematical quantities in this chapter are dimensionless.

Learning Objectives

After studying this chapter, students should be able to:

  • simplify Boolean expressions using identities and canonical forms;
  • relate Boolean algebras to sets, logic circuits and lattices;
  • use partially ordered sets, joins, meets and fixed points in program semantics;
  • distinguish groups, rings, integral domains and fields from their axioms;
  • perform computations in modular rings and finite fields;
  • apply algebraic structures to coding, cryptography and computational systems;
  • identify conditions and limitations governing algebraic algorithms.

Boolean Algebra

Definition and fundamental laws

A Boolean algebra is a structure (B, ∨, ∧, ¬, 0, 1) in which B is a set, ∨ and ∧ are binary operations, ¬ is a unary complement operation, and 0 and 1 are distinguished elements. For all x,y,z ∈ B, the following laws hold:

LawJoin formMeet form
Commutativex ∨ y = y ∨ xx ∧ y = y ∧ x
Associative(x ∨ y) ∨ z = x ∨ (y ∨ z)(x ∧ y) ∧ z = x ∧ (y ∧ z)
Distributivex ∨ (y ∧ z) = (x ∨ y) ∧ (x ∨ z)x ∧ (y ∨ z) = (x ∧ y) ∨ (x ∧ z)
Identityx ∨ 0 = xx ∧ 1 = x
Complementx ∨ ¬x = 1x ∧ ¬x = 0

These axioms imply several useful identities:

x ∨ x = x, x ∧ x = x
x ∨ (x ∧ y) = x, x ∧ (x ∨ y) = x
¬(x ∨ y) = ¬x ∧ ¬y, ¬(x ∧ y) = ¬x ∨ ¬y

The first pair expresses idempotence, the second absorption, and the third De Morgan’s laws. The principle of duality states that a valid Boolean identity remains valid when ∨ and ∧ are exchanged simultaneously with 0 and 1.

Two-element Boolean algebra

Digital logic uses B = {0,1}, where 0 represents false or low and 1 represents true or high. The operations are OR, AND and NOT:

xyx ∧ yx ∨ y¬x
00001
01011
10010
11110

A Boolean function of n variables is a mapping f:{0,1}n → {0,1}. There are 22n such functions because the truth table has 2n rows, and each row can independently receive either output value.

Algebraic simplification

Consider the circuit specification

F = (A ∧ B) ∨ (A ∧ ¬B).

Using distributivity and complementarity,

F = A ∧ (B ∨ ¬B) = A ∧ 1 = A.

Thus, under ideal Boolean logic, the entire circuit can be replaced by a connection carrying A. This reduces gate count, delay and energy consumption. Physical circuits, however, may exhibit propagation delay, fan-out constraints and hazards that Boolean algebra alone does not model.

Canonical forms

A minterm is an AND of every variable or its complement. A maxterm is an OR of every variable or its complement. Any Boolean function can be expressed as:

  • a disjunctive normal form (DNF), an OR of minterms; or
  • a conjunctive normal form (CNF), an AND of maxterms.

For example, if F(A,B)=1 exactly for inputs 01 and 10, then

F = (¬A ∧ B) ∨ (A ∧ ¬B).

This is the exclusive-OR function. Canonical forms guarantee representation but need not minimize circuit size. Karnaugh maps, the Quine–McCluskey algorithm, binary decision diagrams and SAT-based optimization are used for larger problems.

Functional completeness

A set of gates is functionally complete if every Boolean function can be built from it. The sets {¬,∧} and {¬,∨} are functionally complete. NAND alone is also complete because

¬x = x NAND x
x ∧ y = ¬(x NAND y) = (x NAND y) NAND (x NAND y).

NOR alone is similarly complete. This property supports hardware standardization around a small number of gate types.

Lattices and Information Ordering

Partially ordered sets

A partial order ≤ on a set P is reflexive, antisymmetric and transitive. The pair (P,≤) is called a partially ordered set, or poset. Unlike a total order, a partial order may contain incomparable elements.

For subsets of a universe U, inclusion ⊆ is a partial order. Two sets can be incomparable when neither contains the other.

Meets, joins and lattices

For x,y ∈ P, the join x ∨ y is their least upper bound, while the meet x ∧ y is their greatest lower bound. A lattice is a poset in which every pair has both a join and a meet.

In the power-set lattice (𝒫(U),⊆),

X ∨ Y = X ∪ Y, X ∧ Y = X ∩ Y.

The least element is ∅, the greatest is U, and the complement of X is U ∖ X. Consequently, every power set forms a Boolean algebra.

Boolean lattice of subsets of a three-element set 111110101011 100010001000
Hasse diagram of the Boolean lattice of subsets of a three-element set
Figure: Hasse diagram of the Boolean lattice of subsets of a three-element set

Figure: Hasse diagram of the Boolean lattice 𝒫({a,b,c}), with bit strings indicating membership.

The edges represent immediate inclusion. For example, 100 is below both 110 and 101 because {a} ⊂ {a,b} and {a} ⊂ {a,c}.

Complete lattices and fixed points

A complete lattice has a join and meet for every subset, including infinite subsets. If L is a complete lattice and f:L→L is monotone, meaning

x ≤ y ⇒ f(x) ≤ f(y),

then the Knaster–Tarski theorem guarantees that the set of fixed points of f is itself a complete lattice. In particular, f has least and greatest fixed points.

This result underlies data-flow analysis, type inference and denotational semantics. Program properties are ordered by information content, and iterative analysis computes a fixed point. In finite lattices, monotone iteration from the least element eventually stabilizes. In infinite lattices, static analyzers may require widening to force termination, potentially sacrificing precision.

Boolean Reasoning in Program Semantics

A program assertion is a predicate over states. Logical implication orders predicates: P ≤ Q may be defined by P ⇒ Q. Under this convention, stronger predicates contain more information.

A Hoare triple

{P} C {Q}

states that if precondition P holds and command C terminates, then postcondition Q holds. This is a partial-correctness claim. Total correctness additionally requires termination.

Worked verification of a loop

Consider the program:

while x > 0 do
    x := x − 1

Assume explicitly that x ∈ ℤ and initially x ≥ 0. The proposed postcondition is x=0.

Use the invariant I ≡ x ≥ 0.

  1. Initialization: The precondition x∈ℤ ∧ x≥0 establishes the invariant.
  2. Preservation: If x>0 and x∈ℤ, then x≥1. After assignment, x−1≥0, so the invariant is preserved.
  3. Exit: At termination, x≥0 and ¬(x>0), implying x=0.
  4. Termination: The integer-valued variant V=x is nonnegative at every loop head and decreases by exactly 1 on each iteration. Hence the loop terminates after the initial value of x iterations.

The integer-domain assumption is essential. If x were allowed to be a real number such as 0.5, one iteration would produce −0.5, violating both the invariant and the claimed postcondition.

Weakest-precondition reasoning works backward. For assignment x:=E,

wp(x := E, Q) = Q[E/x],

where Q[E/x] denotes capture-avoiding substitution of expression E for free occurrences of x in Q.

Algebraic Structures

An algebraic structure consists of a carrier set together with operations satisfying stated laws. The laws, rather than the notation used for operations, determine the structure.

StructureRequired properties
SemigroupOne associative binary operation
MonoidSemigroup with an identity element
GroupMonoid in which every element has an inverse
Abelian groupGroup with a commutative operation
RingAddition forms an abelian group; multiplication is associative and has identity 1R; multiplication distributes over addition
Commutative ringRing whose multiplication is commutative
Integral domainNonzero commutative ring with 1R≠0R and no zero divisors
FieldCommutative ring with 1F≠0F in which every nonzero element has a multiplicative inverse

Some literature permits rings without a multiplicative identity. That is not the convention adopted in this chapter.

Groups

A group (G,*) satisfies closure, associativity, existence of an identity e, and existence of an inverse g-1 for every g∈G. If g*h=h*g for all elements, the group is Abelian.

Examples include:

  • integers under addition, (ℤ,+);
  • nonzero real numbers under multiplication, (ℝ∖{0},×);
  • invertible permutations under composition;
  • invertible residues modulo n under multiplication.

A subgroup is a subset closed under the group operation and inverses and containing the identity. A cyclic group is generated by one element. In additive notation,

⟨g⟩ = {kg : k ∈ ℤ}.

Lagrange’s theorem states that for a finite group G, the order of every subgroup divides |G|. Consequently, the order of an element also divides |G|. These facts are fundamental in cryptographic protocol design.

Rings and modular arithmetic

A ring (R,+,·,0R,1R) has an Abelian additive group and associative multiplication with identity 1R. Multiplication distributes over addition:

a(b+c)=ab+ac, (a+b)c=ac+bc.

The integers ℤ, residue classes ℤn, square matrices and polynomial rings are important examples. Matrix rings are generally noncommutative.

In ℤn, two integers represent the same residue class when

a ≡ b (mod n) ⇔ n divides (a−b),

where the modulus satisfies n≥2. Addition and multiplication are performed before reducing modulo n.

A residue [a] is a unit in ℤn exactly when gcd(a,n)=1. For example, 5 is invertible modulo 12 because gcd(5,12)=1, and

5 × 5 = 25 ≡ 1 (mod 12).

By contrast, ℤ6 has zero divisors because

[2][3]=[0]

even though neither factor is zero. Therefore ℤ6 is not an integral domain or field.

Fields and finite fields

A field permits addition, subtraction, multiplication and division by nonzero elements. The residue ring ℤp is a field exactly when p is prime. For example, in ℤ7, the inverse of 3 is 5 because 3×5≡1 (mod 7).

A finite field has pm elements, where p is prime and m≥1. Up to isomorphism, a finite field exists for every prime power. When m>1, the field is generally constructed as a quotient of a polynomial ring:

GF(pm) ≅ GF(p)[x]/(f(x)),

where f(x) is an irreducible polynomial of degree m over GF(p). Choosing an arbitrary reducible polynomial would introduce zero divisors and would not produce a field.

Homomorphisms and quotient structures

A homomorphism preserves operations. For groups, a map φ:G→H is a homomorphism if

φ(a*b)=φ(a)*φ(b).

Its kernel is ker φ={g∈G:φ(g)=eH}. An isomorphism is a bijective homomorphism and identifies structures that are algebraically equivalent.

For a unital ring homomorphism under the identity-preserving convention used here, φ(1R)=1S. An ideal I of a ring permits construction of the quotient ring R/I. Quotients formalize modular arithmetic because ℤn≅ℤ/nℤ.

Computational Applications

Chinese remainder decomposition

If moduli n1,…,nk are pairwise coprime, the Chinese remainder theorem gives

ℤ/(n1⋯nk)ℤ ≅ ℤ/n1ℤ × ⋯ × ℤ/nkℤ.

For example, solve x≡2 (mod 3) and x≡3 (mod 5). Testing residues congruent to 2 modulo 3 gives 2, 5, 8, and 8≡3 (mod 5). Thus

x ≡ 8 (mod 15).

The theorem enables parallel modular computation and accelerates RSA implementations. Its uniqueness modulo the product requires pairwise coprime moduli in this stated form.

RSA worked example

RSA uses modular exponentiation in a residue ring. For a small instructional example, choose distinct primes p=11 and q=17. Then

n=pq=187, φ(n)=(p−1)(q−1)=160.

Choose e=7, for which gcd(7,160)=1. Its inverse modulo 160 is d=23 because 7×23=161≡1 (mod 160).

For message representative m=42, encryption gives

c = me mod n = 427 mod 187 = 15.

Decryption gives

m = cd mod n = 1523 mod 187 = 42.

This numerical example is intentionally insecure: practical RSA requires large primes, authenticated padding such as RSA-OAEP, secure random generation, side-channel resistance and carefully managed keys. Textbook RSA must never be deployed directly.

Algebraic path computation

Not every useful computational structure is a ring. In the min-plus semiring, the operations are

a ⊕ b = min(a,b), a ⊗ b = a+b.

Its additive identity is infinity and multiplicative identity is 0. Matrix operations over this semiring express shortest-path algorithms. The absence of additive inverses distinguishes a semiring from a ring.

Applied Case: Error Correction in a Data Link

Background and problem

This illustrative case considers a sensor transmitting four-bit measurements across a noisy industrial link. Single-bit errors occur occasionally, but retransmission is expensive. The system requires a code capable of correcting any one-bit error in each seven-bit block.

Algebraic approach

Use the binary Hamming (7,4) linear code over the field GF(2), where addition is exclusive-OR. A systematic generator matrix is

G = [1 0 0 0 1 1 0;
0 1 0 0 1 0 1;
0 0 1 0 0 1 1;
0 0 0 1 1 1 1].

A compatible parity-check matrix is

H = [1 1 0 1 1 0 0;
1 0 1 1 0 1 0;
0 1 1 1 0 0 1].

All arithmetic is in GF(2), and GHT=0. For message row vector

m=[1 0 1 1],

the encoded word is

c=mG=[1 0 1 1 0 1 0].

Suppose the sixth bit is flipped during transmission:

r=[1 0 1 1 0 0 0].

The syndrome is

s=HrT=[0 1 0]T.

This equals column 6 of H, identifying the erroneous position. Flipping bit 6 reconstructs c, after which the first four systematic bits recover the message 1011.

Outcome and learning points

The system transmits seven bits for every four data bits, a rate of 4/7. The code corrects one error because its minimum Hamming distance is 3. It can detect, but not reliably correct, every two-bit error. The case illustrates why coding theory requires a field: vector-space operations, matrix rank and syndrome decoding depend on well-defined algebraic operations in GF(2).

Limitations, Governance and Professional Practice

Algebraic models abstract away implementation details. Boolean equivalence does not establish electrical safety or timing correctness. Cryptographic correctness does not guarantee secure random-number generation, resistance to side channels or sound key governance. Error-correcting capability depends on the assumed error model; burst errors may require interleaving or different codes.

Professional practice should therefore include:

  • documenting carrier sets, operations and algebraic assumptions;
  • distinguishing rings from fields before applying division;
  • checking primality, coprimality and irreducibility conditions;
  • using established cryptographic libraries rather than custom implementations;
  • applying formal verification to security-critical hardware and software;
  • validating code performance against realistic channel models;
  • managing keys, access rights, retention and audit responsibilities;
  • considering whether encrypted or encoded systems facilitate harmful surveillance or concealment.

Contemporary tools combine these ideas at scale. SAT and SMT solvers automate Boolean and theory reasoning; proof assistants verify algebraic claims; abstract interpreters compute lattice fixed points; and post-quantum cryptography uses lattices, finite fields, rings and error-correcting codes. AI-assisted code generation may help construct formulas or tests, but machine-generated algebra must still be checked against axioms, domains and security requirements.

Chapter Summary

Boolean algebra supports logical reasoning, circuit design and predicate manipulation. Its connection with complemented distributive lattices explains the common structure of logic and set operations. Complete lattices and monotone fixed-point theory provide foundations for program semantics and static analysis.

Groups formalize invertible operations, rings combine additive and multiplicative structure, and fields permit division by every nonzero element. Under this chapter’s convention, every ring has a multiplicative identity. Modular rings, finite fields, polynomial quotients and homomorphisms enable efficient computational representations. These structures support RSA, Chinese remainder computation, Hamming codes and shortest-path algorithms, but their use requires careful attention to domains, theorem conditions and implementation security.

Key Terms

Boolean algebra: A complemented distributive lattice with distinguished elements 0 and 1.

Boolean function: A mapping from {0,1}n to {0,1}.

Canonical form: A standardized Boolean representation such as DNF or CNF.

Functional completeness: The ability of a set of logical operations to express every Boolean function.

Partial order: A reflexive, antisymmetric and transitive relation.

Lattice: A poset in which every pair has a meet and a join.

Complete lattice: A lattice in which every subset has a meet and a join.

Fixed point: An element x satisfying f(x)=x.

Group: A set with an associative operation, identity and inverses for all elements.

Abelian group: A group whose operation is commutative.

Ring: A structure whose addition is an Abelian group and whose associative multiplication has an identity and distributes over addition.

Integral domain: A nonzero commutative ring with identity and no zero divisors.

Field: A commutative ring with distinct zero and identity in which every nonzero element has a multiplicative inverse.

Unit: An element possessing a multiplicative inverse.

Zero divisor: A nonzero element whose product with another nonzero element is zero.

Homomorphism: A mapping that preserves specified algebraic operations.

Ideal: A ring subset suitable for forming a quotient ring.

Finite field: A field containing finitely many elements, necessarily a prime-power number.

Syndrome: A parity-check result used to identify or detect errors in a linear code.

Semiring: A ring-like structure that does not require additive inverses.

Review Questions

Short Answer Questions

  1. State the principle of duality in Boolean algebra.
  2. Distinguish a partial order from a total order.
  3. What multiplicative-identity convention for rings is used in this chapter?
  4. When is an element of ℤn a unit?
  5. What information is carried by the syndrome of a Hamming codeword?

Long Answer Questions

  1. Explain how Boolean algebra is related to digital logic and power-set lattices.
  2. Discuss the role of complete lattices and monotone functions in program analysis.
  3. Compare groups, rings, integral domains and fields, giving a computational example of each.
  4. Explain how quotient polynomial rings are used to construct finite fields.
  5. Describe the algebraic foundations and practical security limitations of RSA.

Analytical / Application Questions

  1. Simplify (A∨B)∧(A∨¬B) algebraically, and describe the corresponding circuit optimization.
  2. Prove total correctness of the loop while x > 0 do x := x − 2 under an appropriate integer precondition and postcondition. Clearly state a valid invariant and variant.
  3. Encode the message [0 1 1 0] using the generator matrix in the case study, introduce an error in bit 5, and use the syndrome to locate and correct it.

Multiple Choice Questions with Answers

Question 1

Which identity simplifies x ∨ (x ∧ y)?

A. Complement law

B. Absorption law

C. Associative law

D. De Morgan’s law

Correct Answer: B. Absorption law

Question 2

How many Boolean functions exist on three Boolean variables?

A. 8

B. 16

C. 64

D. 256

Correct Answer: D. 256

Question 3

In the power-set lattice (𝒫(U),⊆), what is the meet of sets X and Y?

A. X∪Y

B. X∩Y

C. U∖X

D. X△Y

Correct Answer: B. X∩Y

Question 4

Under the convention used in this chapter, which property is required of ring multiplication?

A. Every element has a multiplicative inverse

B. Multiplication is always commutative

C. Multiplication has an identity

D. Multiplication is idempotent

Correct Answer: C. Multiplication has an identity

Question 5

Which residue is the multiplicative inverse of 3 in ℤ7?

A. 2

B. 4

C. 5

D. 6

Correct Answer: C. 5

Question 6

Which of the following residue rings is a field?

A. ℤ6

B. ℤ8

C. ℤ9

D. ℤ11

Correct Answer: D. ℤ11

Question 7

Why is the integer-domain assumption essential for the loop while x > 0 do x := x − 1 with postcondition x=0?

A. Real subtraction is undefined

B. A positive noninteger may step below zero without reaching zero

C. Integers cannot be ordered

D. The loop guard requires modular arithmetic

Correct Answer: B. A positive noninteger may step below zero without reaching zero

Question 8

Solve x≡2 (mod 3) and x≡3 (mod 5). Which is the solution modulo 15?

A. x≡5

B. x≡7

C. x≡8

D. x≡13

Correct Answer: C. x≡8

Question 9

In the Hamming-code case, a syndrome equal to column 6 of the parity-check matrix indicates what?

A. The message has six data bits

B. Bit 6 is erroneous

C. Six errors occurred

D. The codeword is error-free

Correct Answer: B. Bit 6 is erroneous

Question 10

What condition on f(x) is required in the stated construction GF(p)[x]/(f(x)) of GF(pm)?

A. It must be linear

B. It must have integer coefficients only

C. It must be irreducible of degree m

D. It must have every field element as a root

Correct Answer: C. It must be irreducible of degree m

Mathematics for Computer Science
Chapter 6 of 15