📄 Paper 1 · 4.4 Theory of Computation
4.4.2b Sets, Regular Expressions & Regular Languages
AQA 7517 · A-Level Computer Science · ~20 min read

Sets

A set is an unordered collection of distinct elements. In computer science, sets underpin formal language theory.

Set notation

  • — element of: 3 ∈ {1,2,3}
  • — not element of: 4 ∉ {1,2,3}
  • — empty set (no elements): {}
  • — subset: A ⊆ B means every element of A is in B
  • — union: elements in A or B (or both)
  • — intersection: elements in both A and B
  • |A| — cardinality: number of elements in A
  • A* — Kleene star: zero or more concatenations of elements from A

Cardinality examples

A = {a, b, c}   |A| = 3
B = {}          |B| = 0  (empty set)
C = {1,2,3,4}   |C| = 4

Languages and Alphabets

In formal language theory:

  • Alphabet (Σ) — a finite set of symbols: e.g. Σ = {0,1} for binary
  • String — a finite sequence of symbols from Σ: e.g. "011"
  • Empty string (ε) — a string of zero characters
  • Language — a set of strings over Σ: e.g. the language of even-length binary strings
  • Σ* (Sigma-star) — the set of ALL strings over Σ, including ε (Kleene star)

Regular Expressions

A regular expression (regex) is a compact notation for defining a regular language (the class of languages recognised by FSMs).

Core regular expression operators

OperatorSymbolMeaningExample
Concatenationaba followed by bab → {"ab"}
Alternation (OR)a|ba or ba|b → {"a","b"}
Kleene stara*Zero or more a'sa* → {"", "a", "aa", "aaa",...}
Kleene plusa+One or more a'sa+ → {"a", "aa", "aaa",...}
Optionala?Zero or one aa? → {"", "a"}
Grouping(ab)*Zero or more "ab"(ab)* → {"", "ab", "abab",...}

Examples

// All binary strings ending in 1:
(0|1)*1

// Strings of one or more a's followed by one or more b's:
a+b+

// All strings over {a,b}:
(a|b)*

// Binary strings of even length:
((0|1)(0|1))*

// Valid simple email pattern (simplified):
[a-z]+@[a-z]+\.[a-z]+

Regular Languages

A regular language is any language that can be:

  • Described by a regular expression
  • Recognised by a finite state machine (FSM/DFA)
  • Generated by a regular grammar

These three representations are equivalent — they all describe exactly the same class of languages.

Regular vs non-regular languages

RegularNon-regular (requires more powerful model)
Binary strings ending in 0Palindromes
Strings containing "ab"aⁿbⁿ (equal a's and b's)
Identifiers in a programming languageBalanced parentheses
Even-length binary stringsContext-free languages (require PDA)
Exam tip: AQA asks you to write regular expressions and identify strings that match them. Key operators: * (zero or more), | (or), + (one or more), ? (optional), () for grouping. Know that regular expressions and FSMs are equivalent — they describe the same languages. The Kleene star (Σ*) means ALL strings including ε. Non-regular languages (like aⁿbⁿ) cannot be described by a regex — they need a pushdown automaton.
Click through the slides at your own pace. Use arrow keys or click to advance.
Click slide or press arrow keys to navigate

Worksheet — 4.4.2b Sets, Regular Expressions & Regular Languages

8 questions · instantly marked · AQA 7517 standard

Q1State the meaning of the symbols: ∈, ∉, ∅, and |A|.[4]
✅ Mark scheme
Mark scheme
∈ = element of (the item is in the set) [1]; ∉ = not element of (the item is not in the set) [1]; ∅ = empty set (set with no elements) [1]; |A| = cardinality of A (the number of elements in set A) [1].
Q2What does Σ* (Sigma-star) represent in formal language theory?[2]
✅ Mark scheme
Mark scheme
Σ* is the set of ALL strings (including the empty string ε) that can be formed over the alphabet Σ [1]; it represents the Kleene star applied to the alphabet [1].
Q3Explain the meaning of each regular expression operator: *, |, +, and ?[4]
✅ Mark scheme
Mark scheme
* (Kleene star): zero or more occurrences [1]; | (alternation): one pattern OR another [1]; + (Kleene plus): one or more occurrences [1]; ? (optional): zero or one occurrence [1].
Q4Write a regular expression to describe all binary strings that begin with 1.[2]
✅ Mark scheme
Mark scheme
1(0|1)* [2] — starts with 1 [1], followed by zero or more of (0 or 1) [1].
Q5Write a regular expression that matches strings of one or more digits (0–9).[2]
✅ Mark scheme
Mark scheme
(0|1|2|3|4|5|6|7|8|9)+ or [0-9]+ [2] — any digit character [1]; one or more (+) [1].
Q6State three equivalent ways to describe a regular language.[3]
✅ Mark scheme
Mark scheme
Regular expression [1]; finite state machine (DFA/NFA) [1]; regular grammar [1]. All three are equivalent descriptions of regular languages.
Q7Give one example of a language that is NOT regular and explain why an FSM cannot recognise it.[2]
✅ Mark scheme
Mark scheme
aⁿbⁿ (equal number of a's and b's) [1]; an FSM has finite memory (no counting) so it cannot track how many a's it has seen to ensure an equal number of b's follow [1]. Accept: balanced parentheses / palindromes + valid explanation.
Q8What strings are matched by the regular expression (ab)+|c* ?[3]
✅ Mark scheme
Mark scheme
(ab)+: one or more repetitions of "ab" → "ab", "abab", "ababab",... [1]; c*: zero or more "c" → "", "c", "cc", "ccc",... [1]; the | means the expression matches either pattern — strings from (ab)+ OR strings from c* [1].
Topic Quiz
Question 1 of 15
You scored
out of 15
Card 1 of 9
Click to reveal definition
🎉
All cards reviewed!
TermDefinition
🎯

Mini Test — Sets & Regular Expressions

10 questions · 10 minutes

← 4.4.2a Finite State Machines
28 of 70 · AQA 7517
4.4.3 BNF & Syntax Diagrams →