Sets, Relations, and Languages: Prepared By: Prof. Manuel C. Cabido
Sets, Relations, and Languages: Prepared By: Prof. Manuel C. Cabido
Languages
Prepared by: Prof.
Manuel C. Cabido
SET
► SYMBOL SYMBOL NAME
MEANING / DEFINITION a collection of EXAMPLE
► {} set
elements so that A = {3,7,9,14}, B =
► | such that
objects that belong to set A and set B A = { x | x e , x <0}
► APB intersection
objects that belong to set A or set B A PI B = {9,14}
► AUB union
A U B = {3,7,9,14,28}
► AQB subset
A is a subset of B. set A is included in set B. {9,14,28} Q {9,14,28}
► AcB proper subset / ,28}
strict subset A is a subset of B, but A is not equal to B. {9,14}
► A£B not subset
set A is not a subset of set B {9,66} £ {9,14,28}
► A^B superset
A is a superset of B. set A includes set B {9,14,28} ^ {9,
► A=>B proper superset
/ strict superset A is a superset of B, but B is not equal to A.
{9,14,28 = {9,14}
► }
set A is not a superset of set B {9,14,28} 2 {9,66}
► A2B not superset
SET
SYMBOL
SYMBOL NAME MEANING / DEFINITION EXAMPLE
► 2A
power set all subsets of A
► P(A)
power set all subsets of A
► P(A)
power set all subsets of A
► A=B B={3,9,14},
equality both sets have the
► Ac
same members A={3,9,14},
► A’
complement all the objects
► A-B
that do not belong to set A
Set difference {x | x e A; x £
B}
Relations and Functions
► Ordered Pair
► (a,1) * {a,1}
Cartesian Product
►
A x B = {(a,b) | a e A and b e B}
= {(a,1), (a,2), (a,3), (b,1), (b,2), (b,3)}
► Ex:
► {(a,1),(b,2)}
Graphs of Relations
► Given a set A = {a,b} , the cartesian product AxA = {(a,a),(a,b),(b,a),(b,b)}
► Let R = {(a,a),(a,b),(b,b)} be a relation in AxA
1 R S
Equivalence Relation
► Let A be a set.
1
transitive.
► Def. Let R be an equivalence relation on a set A. The equivalence class of
[a] = { b| (a,b) £ R }
Graphs of Reflexive, Symmetric and
Transitive Relations
►
R is not an equivalence relation S is an
►
equivalence relation
► S is reflexive; V a £ A, (a,a) £ S
R
Closures
► Let A = {a,b,c,d}. Consider two directed graphs R and R* shown below. R*
contains R; also , R* is reflexive and transitive. Thus, R* is the reflexive
transitive closure of R.
► Def. Let R Q AxA be the directed graph defined on set A. The reflexive
transitive closure of R is the relation
► Let N+ be the set of all positive integers. Let plus ={(a,b)| a,b £ N+} Q N+xN+ be
a binary relation on set N+. The subset M of N+ is said to be closed under plus if
a+b £ M whenever a,b £ M and (a,b) £ plus.
► Thus, the set of all positive integers N+ is closed under the relation + because for
any number a,b £ N+ , a+b £ N+ .
Alphabets and Languages
► Ex. I = {a,b,...,z}
► I = {0,1}
► w=aabcde
► I* is the set of all strings, including the empty string over the alphabet I.
► Substring.
► A string v is a substring of string w if and only if there are strings x and y such that
w=xvy. For the empty sting €, €v = v€ for some string v.
i
► If w=vx for some string x, then v is a prefix of w.
► For each string w and each natural number I, the string w1' is defined as
► w0 = e
► Reverse of a string
► The reversal of a string w, denoted by wR , is the string “spelled backward”
► Formal Definition
► 1. If w is a string of length 0, then wR = w = €
► Language
► Any set of string over an alphabet I is called a language.
► L = {w £ I* : w has property P }
Languages
► Since languages are sets, they can be combined by the set operations:
► 1. Union L 1 U L2
► 2. Intersection L 1 H L2
► 3. Set Difference L1 - L2
► 4. Concatenation L 1 L2
► L* is the set of all strings obtained by concatenating zero or more strings from L.
► Formally
► L* = { w £ I* : w = w-,w2...wk for some k > 0 and some w-,,w2,...,wk £ L }
Ex.
►
Let L = {01,1,100} then
►
10010111 £ L* since 100,1,01,1,1 £ L
►
Let I = {a}
►
L0 = {£}
►
L1 = {a}
►
L2 = {aa}
►
► L = {aa...a} n number of a.
n
The Language L+
► The REGULAR EXPRESSION over the alphabet I are all strings over the
= (a,bj*{aj
►
= {w e {a,b}* : w ends with an a}
Regular Languages
► The class of regular languages over an alphabet I is defined to consist of all languages
L such that L = f( a) for some regular expression a over I.
► Regular languages are all languages that can be described by a regular expression,
► The class of regular languages over I is precisely the closure of the set of languages
► {{5} : 5 e 2 } U {0}
► with respect to the functions of union, concatenation and Kleene Star.