Algo Midterm
Algo Midterm
xiv. Other examples: L2 ❑¿, L2 = {a n b n : n0 } this includes and contains all words with n number of letters;
L3 ❑¿, L3 = { x : ¿a ( x ) =2¿ b ( x ) } this includes and will include 2x more a’s for each b
xv. Language are sets; we can perform any of the normal set operations on languages; union, intersection,
complement; we can concatenate 2 languages; ex: L1 L2 = { x 1 x 2 : x 1 L1 , x2 L2 } we take any element from
L1 and concatenate it with the element of L2 and combine together
xvi. Lexical ordering the words are grouped in order of increasing length, and within each group the words
are alphabetical; the lexical order of ❑¿ is , a, b, aa, ab, ba, bb, aaa, aab, aba, abb, baa, bab, bba, bbb, …
xvii. Language classifications regular languages; context-free languages; a language that is regular is also
context-free but there are context-free languages that are not regular
xviii. Grammar a grammar is a set of rules; a rule has 1+ symbols on the left side and 0+ on the right side;
grammar is used to derive words of a language; repeatedly replace symbols based on the production rules;
the language is the set of all the words that can be derived from the rules of the grammar; ex: {S aSb, S
} generates and the same set of a’s and b’s {, ab , aabb ,aaabbb , …}, {SaSb, SbSa, SSS,S}
generates and same # of a’s and b’s are added
c. Finite automata determines the words that are in a language; works using internal states/finite, an input tape, and
transition function; the automaton examines the current state and the next input symbol, transition function is used
to determine the new state; will output a simple accept or reject to indicate whether the input word is in the
language that the finite automaton is designed for; some of the states are identified as accepting state; if a finite
automaton stops in an accepting state after reading all of the input symbols, the word is accepted and is in the
language
i. Graph representation of finite automata draw a transition graph; draw a circle for each internal state;
draw an arrow for each transition from the old state to the new state, place the input symbol above the
arrow; double circle indicates the accepting state(s)
ii. Finite automaton: configuration a pair of elements (x, y); the 1st element represent the current state; the
2nd element represents the part of the input word yet to be examined; (current state, current string)
iii. Regular languages finite automata can be written to accept a variety of languages; but not all languages
in ❑¿; languages that we can write finite automata for are called regular languages; regular languages
include the set of reserved words for programming languages and the set of possible variable names,
operators
iv. Regular expressions a regular language can be described by a regular expression; rules for creating
regular expressions: 1.) , , and all symbols are primitive regular expressions, 2.) If r, r1, r2 are regular
expressions, then so are r1, +r2, r1*r2 and (r), 3.) A string represents a regular expression if and only if
symbols of step 1 and repeated application of step 2 can create it; represents the empty language that has
no words, represents an empty element in a language; regular expressions are associative operations (+
operator: union, . operator: concatenation, * operator: star closure); ex: (aaa)* includes and any # of aaa’s,
a*b* includes and any # of a’s and b’s, (a+b)* bbb(a+b)* includes any string made up of a’s and b’s but
must include bbb in the middle
v. Deterministic finite automata (DFA) means every state has exactly one edge leaving it for each of the
symbols of the alphabet; an input word will cause the exact same behavior every time a deterministic finite
automaton is run on that word
vi. Nondeterministic finite automata (NFA) a state can have no edges for a symbol or can have multiple
edges for a symbol; it may have edges labeled , such edge can be taken without consuming any of the input
symbols; NFA will accept a word if there is at least one path through the automaton that consumes all of the
symbols of the input and winds up in an accepting state; for a word to be rejected, all possible paths through
the automaton must reject the word; any language that can be decided by a DFA can also be decided by a
NFA and vice versa
vii. Transition function for DFA ((s1, a) = s2; each old state and input symbol combination leads to exactly
one new state) for NFA ((s1, a) = S; S is the set of states that can result from an old state of s1 and an input
symbol of a; Set S can have 0+ elements corresponding to the # of edges leaving state s1 that are labeled
with an a symbol)
d. Design finite automata figure what words are in and not in the language and what is the pattern of the language
words; create the states and transitions we need to accept these words; finite automata restrictions (limits to the type
of languages they can accept; good at finding patterns and can count but up to known #s; they do not have any
memory and cannot compare one part of a word with another)
e. Design regular grammar think of each of the nonterminal symbols as having a meaning or purpose; A aaB, A
has the purpose of adding two a symbols to the word;
f. Finite automata equivalence and limitations DFA and NFA are equivalent; we can prove this by showing that we
can convert any NFA to DFA; subsets of states will be used as labels for the states of a new and equivalent DFA;
starting state of new DFA is labeled with the set containing the NFA initial state and all of the states that can be
reached from it with just edges, then from a state in the new automata, which is a set of old states and an input
symbol, the destination new state is the union of all the places we can get from old states in the set using the
symbols, continue to examine the reachable destinations for every symbol and each new set we produce until we
stop producing new sets