Skip to main content

Set Theory



Welcome to the very first milestone of your ZK learning journey. FYI, Set theory was the first math topic our university professor taught us. I am going to apply the same here also. This is the foundational brick that lays the pillar for the rest of the other lessons to come as it isolates the kind system and numbers we need to work with. In ZK, you cannot just work with any number however you like. We need to define the set of numbers ZK works with.


1. Set Definition & Element Membership (∈, ∉)​

A set is just a collection of similar elements & objects together. Think of it like a bucket or a structural data container. Inside this bucket, you can throw inside anything you want: numbers, letters, shapes, or coordinate points. The individual items inside the bucket are called elements.

In mathematical notation, we enclose our set elements inside curly brackets like this {}. For example, a set of A has elements made up of :

A = {1, 2, 3}, thus its elements are 1, 2 & 3

Shorthand Membership Symbols​

  • The ∈ symbol means "is an element of" (it lives inside the set).
  • The ∉ symbol means "is not an element of" (not part of the set).

Simple Example:​

Let's define a set of healthy snacks named S:

S = {Apple, Banana, Orange}
  • Apple ∈ S (This is true; Apple lives inside our snack bucket).
  • Pizza ∉ S (This is true; Pizza is not part of the bucket).

There are some certain rules defining how set behaves:

  1. Order of elements does not matter: A bucket holding the numbers 1, 2, and 3 is theoritically identical to another bucket holding the same numbers but orgainzed differently 3, 1, and 2.
Set A = {1, 2, 3}
Set B = {3, 1, 2}
Therefore: Set A = Set B
  1. No duplicate elements allowed: If you throw letter 'a' into a set twice, it ignores the second one.
double collection {a, a, b} is automatically condensed down to: {a, b}

2. Set Cardinality (|S|)​

Up to this point, we need a way to measure our set or rather buckets as i defined it. Cardinality is simply the total number of unique elements living inside a set. We denote cardinality by wrapping the set's variable name inside two vertical bars like this |S|.

Example:​

If A = {5, 9, 10}, then |A| = 3
If B = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, then |B| = 11

When dealing with size of a set, there are two distinct categories based on how we count their elements. There are many more classifications, but let me stick to this to make things simple.

  • Countably Infinite (e.g., Integers ℤ): A set is countably infinite if you can list its elements out one by one in a sequence (1, 2, 3, 4...). Even though the list goes on forever, you can step from one distinct item directly to the next.
  • Uncountably Infinite (e.g., Real Numbers ℝ): A set is uncountably infinite if the elements are so dense that it is impossible to create a sequential list. Between any two real numbers (like 0 and 1), there is a smooth, continuous blur of infinite decimals (0.1, 0.001, 0.00001...) with no clear "next" number.

Zero-knowledge proofs and modern cryptography strictly avoid the use of continuous Real Numbers and because of this, we typically use Integers on Prime Fields to make all our calculations only around certain prime number. We shall come to discuss this in depth in topics like Modular arithmetics and Finite Field elements in the coming lessons.


3. Universal Set (U), Subsets (⊆), & Power Sets​

For simplicity, subset just means fits inside or equal to, while, proper subset means strictly smaller

Now you can tackle the messy explanation by first establishing boundaries of a set. For example, if a set is made up of all lower case letters, then number 5 is not allowed to be within the set. The Universal Set (denoted by U) is the locked boundary where only certain known elements are allowed to exist within a set. Nothing else is permitted to exist outside of U. In below example, the Universal Set U is the set of all lowercase English letters.

U = {a, b, ..., z}

Once you have a parent bucket, you can carve out smaller, isolated collections from it called subsets. Set A is called a subset of B (denoted as A ⊆ B) if every single element sitting inside bucket A also lives inside bucket B.

To see this in action, let's use the standard number example. Imagine our Universal Set U is the set of all Real Numbers (ℝ) - which is every continuous number line value like -5, 0, 0.75, or π.

We can carve out smaller sub-buckets from this large playground:

  • Integers (ℤ): The set of whole numbers like {-2, -1, 0, 1, 2}, become a subset within the larger set U.
  • Rational Numbers (ℚ): The same case also applies to the set of all fractions or quotients like 1/2, -3/4, or 5/1 , which also becomes a subset of U .

Because every single whole integer can also be written as a fraction (e.g., 3 is just 3/1), the entire set of Integers lives inside the set of Rational Numbers. And because every fraction is a valid point on the continuous real number line, all Rational Numbers live inside the Real Numbers.

Mathematically, we write this clean chain of subsets as:

ℤ ⊆ ℚ ⊆ ℝ
(The scary math here means: Integers are a subset of Rationals,
which are a subset of Reals)

Remember a subset must not necessarily be smaller than its parent set. If a subset is strictly smaller than its parent set (meaning the parent has at least one extra element not found in the subset), it is called a proper subset. For example, ℤ is a proper subset of ℚ because 1/2 is a rational number but it is definitely not a whole integer.

For the final clicks, you can check on this image below!

Subset and Proper Subset Diagram


What is a Power Set (P(S))?​

If you list out every single possible subset variation you could ever make from a set, you have created its Power Set.

Because the power sets of infinite systems like ℝ or ℤ are impossibly large to visualize, let's look at a tiny register subset S containing just three whole integers:

S = {1, 2, 3}

If you sit down and write out every single possible sub-bucket combo you can pack using those three numbers, you get its complete Power Set, denoted as P(S):

P(S) = { ∅, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3} }

Can you notice two creepy zombies hidings in the Power Set above?

  1. The Empty Set (∅) is always included because choosing "nothing" is a valid way to make a sub-bucket.
  2. The original set itself ({1, 2, 3}) is always included because a set is always a subset of itself.

4. Cartesian Product​

Sometimes a system needs to handle multiple variables, states, or grid signals at the exact same time. To do this, we need to use Cartesian Product which is simply the collection of every single possible coordinate pair (x, y) you could ever make from your sets in a multi-dimensional coordinate space (written as A × B).

Simple Example:​

Let's say variable x comes from set A and variable y comes from set B:

Set A = {1, 2, 3}
Set B = {x, y, z}

The Cartesian product A × B generates our total lookup coordinate grid:

xyz
1(1, x)(1, y)(1, z)
2(2, x)(2, y)(2, z)
3(3, x)(3, y)(3, z)
A × B = { (1,x), (1,y), (1,z), (2,x), (2,y), (2,z), (3,x), (3,y), (3,z) }

Some of the rules of Cartesian Products include:

A. Position is Everything: The Ordered Pair: Unlike normal sets where order is completely ignored such that {a, b} is the same as {b, a}, the Cartesian product deals with Ordered Pairs written in smooth parentheses: (x, y), where x is the element from the first set and y is the element from the second set.

B. The Multiplication Rule (Cardinality): To find out how big your coordinate matrix will be, you just multiply the sizes of the two sets together.

Let me get a bit mathy terms here, Dont worry about the weird terms for now. But as someone who wants to learn ZK, be ready for math-heavy jargons because this is what dictates the security of ZK protocols. I promise i won't be too hard for now.

Relations vs. Functions​

Both functions and relations are derivatives of the Cartesian Product.

  • A Relation: Any arbitrary collection of coordinate pairs chosen from a Cartesian product. One x input is allowed to link to multiple different y outputs at the exact same time.

For example, if we have a look at this equation y² = x³ - 4x + 9 which we will coming to it in the coming lessons, the left y side is quadratic even though the whole equation is cubic. Never mind, this just means the if you take one x input, say 2, you get two possible y outputs, that is +3 & -3.

  • A Function: A Function is built strictly on top of a relation. In fact, every function is a relation, but it must follow strictly one rule: Every input x can map to exactly one unique output y. For Example, (f(x) = x + 5), f(x) = y here maps to only & exactly 7 if we take x as 2.

We shall get to Geometry of Elliptic Curves later and by understanding that a curve is a static mathematical relation inside a multi-dimensional coordinate space, and that you can easily track and manipulate multiple point coordinates later without breaking the strict laws of unambiguous function mapping.


5. Mathematical Set-Builders & Predicates​

Say you want to filter a simple set of 0 & 1 from infinite integer set of 0,1,2....infinity!

If you come from programming background, you are used to if and else statements used for filtering events. Right? ...Don't panic, we are not doing that.....just know this and forget about that. The question is that, how do you filter elements from an infinite set? Typing out every single element works fine for small sets, but what if your set contains thousands or millions of numbers? This is mathematically tedious.

To solve this, we use a template shorthand called a Set-Builder. Think of a set-builder as an automated filter rule or a security guard standing at a door. The rule itself is called a Predicate. The predicate evaluates an object and yields a binary result: either TRUE or FALSE. If the item satisfies the rule, it is allowed into the new bucket.

For our case here, the predicate is x • (x - 1) = 0 while the set-builder is the whole line.

The scary mathy notation looks like this:

C = { x ∈ ℤ | x • (x - 1) = 0 }

Don't panic, let me help you dissect the math: The vertical bar ( | ) simply means "such that":

"Set C is a collection of numbers (x) coming from the global integers (ℤ), such that they satisfy the algebraic rule x • (x - 1) = 0."

If you evaluate this filter, only two numbers in the universe yield TRUE: 0 and 1.

Filtered Output: C = {0, 1}

This marks the end of the first lesson of Seth Theory.

Quick Assignment: After this Set theory lesson, now go and do research and learn about sets of Rational numbers, Integers & Whole numbers as you figure out which set is used in ZK and which is not. Remember you will come across a lot of these terminologies in all of the coming mathematical operations.



Click Next below to advance to Lesson 2.