263-2200
Types and Programming
Languages
1 / 34
Outline
Boolean Algebra
Values and Operations
Axioms and Theorems
Set Theory
Set Notation and Operations
Relations
Multisets and Sequences
Multisets
Sequences and Tuples
Graphs and Trees
Graphs
Trees
Directed Graphs
2 / 34
Outline
Boolean Algebra
Values and Operations
Axioms and Theorems
Set Theory
Set Notation and Operations
Relations
Multisets and Sequences
Multisets
Sequences and Tuples
Graphs and Trees
Graphs
Trees
Directed Graphs
3 / 34
Review of Boolean Algebra
I
Boolean Value: true = 1
I
Boolean Value: false = 0
I
Boolean Type = {true, false} = {1, 0} = all Boolean values
I
A proposition is a statement that is either true or false.
4 / 34
Boolean Operations
conjunction
disjunction
negation
implication
implication
equivalence
and
or
not
only-if
if
if-and-only-if
∧
∨
¬
→
←
↔
∗
+
−
0
≡
5 / 34
Signatures of Boolean Operators
and
or
not
→
←
↔
:
:
:
:
:
:
Boolean ∗ Boolean → Boolean
Boolean ∗ Boolean → Boolean
Boolean → Boolean
Boolean ∗ Boolean → Boolean
Boolean ∗ Boolean → Boolean
Boolean ∗ Boolean → Boolean
6 / 34
Precedence of Boolean Operators
Level 1 (lowest):
Level 2:
Level 3:
Level 4:
Level 5 (highest):
↔
→, ←
∨
∧
¬
7 / 34
Truth Table Semantics of Some Basic Operations
F
0
0
1
1
G
0
1
0
1
¬F
1
1
0
0
F ∧G
0
0
0
1
F ∨G
0
1
1
1
8 / 34
Equational Semantics of Some Basic Operations
F ↔G
F ←G
F →G
=
=
=
(F → G) ∧ (F ← G)
G→F
¬F ∨ G
9 / 34
Boolean Axioms
Commutative =
(p ∧ q) ∧ r = p ∧ (q ∧ r )
(p ∨ q) ∨ r = p ∨ (q ∨ r )
p ∧ (q ∨ r ) = (p ∧ q) ∨ (p ∧ r )
p ∨ (q ∧ r ) = (p ∨ q) ∧ (p ∨ r )
Associative =
Distributive =
p∧q =q∧p
p∨q =q∨p
10 / 34
Identity =
p ∧ true = p
p ∨ false = p
Negation =
p ∨ ¬p = true
p ∧ ¬p = false
11 / 34
Boolean Theorems and Observation
Double Negation =
Universal =
¬(¬p) = p
p∧p =p
p∨p =p
¬(p ∧ q) = ¬p ∨ ¬q
¬(p ∨ q) = ¬p ∧ ¬q
Idempotent =
De Morgan =
p ∨ true = true
p ∧ false = false
12 / 34
p ∨ (p ∧ q) = p
p ∧ (p ∨ q) = p
¬true = false
¬false = true
Absorption =
Negation II =
13 / 34
Outline
Boolean Algebra
Values and Operations
Axioms and Theorems
Set Theory
Set Notation and Operations
Relations
Multisets and Sequences
Multisets
Sequences and Tuples
Graphs and Trees
Graphs
Trees
Directed Graphs
14 / 34
Basic Values and Notation
I
Empty Set = {} = ∅
I
Universal Set = U
I
The set of all elements x satisfying the Boolean formula
(i.e., the predicate) P is denoted:
{x | P(x)}
15 / 34
Other Notations for Describing Sets
I
Dot-dot notation:
{1, 2, 3, ...}
{1, 2, 3, ..., 10}
I
Regular Expressions
I
Context-free Grammars
Set type – all legal sets including the empty set and the
universal set.
16 / 34
Set operations
member
intersection
union
compliment
subset
proper subset
superset
proper superset
equivalence
difference
power set
cardinality
∈
∩
∪
A
⊆
⊂
⊇
⊃
≡
−
P(A)
|A|
or Ac
17 / 34
Signatures of set operators:
∈
∩
∪
A
⊆
⊂
⊇
⊃
≡
−
P(A)
|A|
:
:
:
:
:
:
:
:
:
:
:
:
element ∗ set → Boolean
set ∗ set → set
set ∗ set → set
set → set
set ∗ set → Boolean
set ∗ set → Boolean
set ∗ set → Boolean
set ∗ set → Boolean
set ∗ set → Boolean
set ∗ set → set
set → set
set → integer when A is a finite set
18 / 34
Precedence of set operators:
Remark
Oftentimes parenthesis is the only convention used to indicate
order of evaluation.
Level 1 (lowest):
Level 2:
Level 3:
Level 4:
Level 5:
Level 6 (highest):
≡
⊆, ⊂, ⊇, ⊃
−
∪
∩
A
19 / 34
Semantics of set operators:
A∪B
A∩B
A
=
=
=
{x|x ∈ A ∨ x ∈ B}
{x|x ∈ A ∧ x ∈ B}
{x|x 6∈ A} = U − A
A−B
=
=
{x|x ∈ A ∧ ¬(x ∈ B)} = {x|x ∈ A ∧ x 6∈ B}
A∩B
A≡B
A⊆B
A⊂B
A⊇B
A⊃B
P(A)
|A|
=
=
=
=
=
=
=
∀x : x ∈ A ↔ x ∈ B
∀x : x ∈ A → x ∈ B
(∀x : x ∈ A → x ∈ B) ∧ A 6≡ B
B⊆A
B⊂A
{s|s ⊆ A}
the number of elements in A
20 / 34
Remarks
I
Terminology: Two sets are disjoint if A ∩ B = ∅
I
The tuple ( ∅, U, union, intersection, compliment ) forms a
Boolean algebra – meaning the boolean axioms and
theorems hold for sets.
21 / 34
Review of Relations
A relation, R, on sets A and B is a set of ordered pairs.
R = {(a, b)|a ∈ A ∧ b ∈ B}
Oftentimes we write a R b to mean (a, b) ∈ R.
Definition
Let R be a binary relation on a set A.
1. R is reflexive iff ∀a ∈ A : a R a
2. R is symmetric iff ∀a, b ∈ A : a R b → b R a
3. R is antisymmetric iff ∀a, b ∈ A : a R b ∧ b R a → a = b
4. R is transitive iff ∀a, b, c ∈ A : a R b ∧ b R c → a R c
22 / 34
Definition
Let R be a binary relation on a set A.
1. R is a preorder iff R is reflexive and transitive.
2. R is a partial order relation iff R is reflexive, antisymmetric,
and transitive.
3. R is an equivalence relation iff R is reflexive, symmetric,
and transitive.
23 / 34
Outline
Boolean Algebra
Values and Operations
Axioms and Theorems
Set Theory
Set Notation and Operations
Relations
Multisets and Sequences
Multisets
Sequences and Tuples
Graphs and Trees
Graphs
Trees
Directed Graphs
24 / 34
Multisets
Definition
A multiset is an extension to the notion of a set in which
collections can contain repeated elements. For example, {3, 8}
and {3, 8, 8} denote two different multisets. However, {3, 8, 8}
and {8, 8, 3} denote the same multiset.
25 / 34
Sequence
I
A sequence of objects is a list of these objects in some
order.
I
Enclosing a comma-separated list of objects in parenthesis
indicates that the list is a sequence.
I
A sequence can be seen as an extension to the notion of a
multiset where the notion of order (or position in the list)
matters.
I
Finite sequences are also called tuples.
I
A sequence having k elements is a k -tuple.
26 / 34
Outline
Boolean Algebra
Values and Operations
Axioms and Theorems
Set Theory
Set Notation and Operations
Relations
Multisets and Sequences
Multisets
Sequences and Tuples
Graphs and Trees
Graphs
Trees
Directed Graphs
27 / 34
I
An undirected graph, or simply a graph, can be defined by
G = (V , E) where V : Id and E : Id ∗ Id.
I
Elements of V are called nodes or vertices.
I
Elements of E are called edges.
I
An edge is a tuple of the form V ∗ V .
28 / 34
I
In an undirected graph, the order of the elements in an
edge tuple does not matter. That is, (vi , vj ) = (vj , vi ).
Another way of thinking about this is that the pair of
vertices in an edge is represented as a set (and not a
sequence/tuple).
I
A graph can be pictorially represented by drawing elements
of V as labelled dots (or small circles) and elements of E
as lines connecting corresponding labelled dots.
29 / 34
I
The degree of a node v ∈ V is equal to the number of
edges in e ∈ E in which v occurs. Pictorially, it is equal to
the number of lines that connect v to other nodes in the
graph.
I
A subgraph of a graph G1 = (V1 , E1 ) is a graph
G2 = (V2 , E2 ) such that V2 ⊆ V1 ∧ E2 ⊆ E1 .
I
A path in a graph is a sequence of nodes connected by
edges. Formally, given G = (V , E) the sequence
(v1 , v2 , ..., vn ) is a path if
vi ∈ V ∧ ∀i : 1 ≤ i < n → (vi , vi+1 ) ∈ E ∨ (vi+1 , vi ) ∈ E.
I
A path (v1 , v2 , ..., vn ) is a simple path if vi = vj ↔ i = j.
30 / 34
I
A graph G = (V , E) is connected if it is true that ∀vi , vj ∈ V
there exists a path of the form (vi , ..., vj ).
I
A path (v1 , v2 , ..., vn ) is a cycle if v1 = vn .
I
A simple cycle is a cycle (v1 , v2 , ..., vn ) such that n ≥ 3
which contains no subsequences that are themselves
cycles.
31 / 34
Trees
I
A tree is a graph that is connected and has no simple
cycles.
I
In a tree, nodes of degree 1 are called the leaves of the
tree.
I
In a tree, a special node is (often) designated to be the
root.
32 / 34
Directed Graphs
I
A directed graph is a graph in which the order of vertices in
edges matters. That is, (vi , vj ) 6= (vj , vi ).
I
A directed edge (vi , vj ) can be pictorially represented by
drawing an arrow from vi to vj .
I
Given a directed graph G = (V , E). The outdegree of a
node v1 ∈ V is equal to the number of edges e ∈ E of the
form (v1 , v2 ). The indegree is equal to the number of
edges of the form (v2 , v1 ).
33 / 34
Directed Graphs
I
Given a directed graph G = (V , E). A path (v1 , v2 , ..., vn ) is
said to be a directed path if ∀i : 1 ≤ i < n → (vi , vi+1 ) ∈ E
I
A directed graph is strongly connected if a directed path
connects every two nodes.
34 / 34
© Copyright 2026 Paperzz