CECS 329 Midterm Review

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Write the language of all sequences of characters from Σ = {0,1} that contain two consecutive 1s as a regular expression

(0 U 1)* o 1 o 1 o (0 U 1)*

Notation for encoding objects into strings..

- If 𝑂 is some object (e.g., polynomial, automaton, graph, etc.),we write 〈𝑂〉 to be an encoding of that object into a string. - If 𝑂1 , 𝑂2 , ... , 𝑂k is a list of objects then we write 〈𝑂1 , 𝑂2 , ... , 𝑂k〉to be an encoding of them together into a single string

A set X is...

Finite if |X| < ℵ₀ Countably infinite if |X| = ℵ₀ Uncountable |X| > ℵ₀

How many states does DFA have?

Finitely many

How does TM recognize {a ^k b^k c^k | k ≥0}

Follow these steps: 1. Mark an a: Starting from the left, mark the first a (e.g., change it to X). 2. Find a matching b and c: Move right to find the first unmarked b, mark it (e.g., change it to Y), then continue to find the first unmarked c and mark it (e.g., change it to Z). 3. Repeat: Go back to the start and repeat this process, marking one a, one b, and one c per pass. 4. Check completion: When all symbols are marked and no unmarked a, b, or c remains, the TM accepts the input. If there's any leftover symbol or a mismatch, it rejects. This approach ensures the counts and order of a's, b's, and c's match exactly.

What is ∀?

For all

What is nondeterminism?

For each input symbol, there may be multiple possible transitions from a given state. The system can choose between these transitions, or it can follow several possible paths simultaneously.

Cartesian Product

If A and B are two sets, the Cartesian product of A and B, denoted by A × B, is defined as: A × B={(a,b) ∣ a ∈ A and b∈B} This means that the Cartesian product includes all ordered pairs (a, b) where a is an element from set A and b is an element from set B. Example: Let's say we have the following sets: A = {1, 2} B = {x, y} The Cartesian product A × B is: A×B={(1,x),(1,y),(2,x),(2,y)} So, the set A × B contains all combinations of the elements from A and B.

Proper Subset

If A ⊆ B, but A is not equal to B, we say A is a proper subset of B (denoted A ⊂ B). This means A contains some, but not all, elements of B. For example, if A = {1, 3} and B = {1, 2, 3}, then A ⊂ B.

What does determinism mean?

In a deterministic system, for each input symbol, there is only one possible transition from any given state. The next state is uniquely determined by the current state and the input symbol being read. Example. Example: If the DFA is in state q1​ and reads the input symbol a, there is exactly one state it can transition to (say, q2​).

Example on how to generate a string from G1. S -> 0S1 S -> R R -> ε

Let's start generating a string by applying the first rule repeatedly. Here's how we can do it: 1. Start with the Start Symbol: S 2. Apply the Rule S→0S1: S⇒0S1 3. Apply the Rule S→0S1 again on S: 0S1⇒00S11 4. Apply the Rule S→R on S 00S11⇒00R11 5. Apply the Rule R→ϵ: 00R11⇒0011 Resulting String So, one possible string generated by the grammar G1​ is: 0011

Let Σ be an alphabet. A language A ⊆ Σ* is called regular if there is a finite automation M such that....

M recognizes A, A = L(M) and A is the regular language of M

CFG Formal Definition.

A CFG is a 4 tuple (V, Σ, R, S) V -> finite set of variables Σ -> finite set of terminal symbols R -> finite set of rules (rule form: V -> (V U Σ)*) S -> start variable

What makes up a DFA?

A Deterministic Finite Automata (DFA) is a 5 tuple (Q, Σ, δ, q0, F) Q -> finite set of states Σ -> alphabet δ -> transition function q0 -> start state F -> set of accept states

What is a Mult-tape Turing Machine?

A Multi-tape Turing Machine is an extension of the standard Turing Machine that has multiple tapes, each with its own read/write head. It can read, write, and move independently on each tape, allowing for more efficient computations by handling multiple pieces of data simultaneously. Although it's more powerful in practice, it has the same theoretical computational power as a single-tape Turing Machine, meaning it can recognize and decide the same classes of languages.

What makes up an NFA?

A Nondeterministic Finite Automata (DFA) is a 5 tuple (Q, Σ, δ, q0, F) Q -> finite set of states Σ -> alphabet δ -> transition function q0 -> start state F -> set of accept states But now with δ you can accept epsilon transitions. (δ:Q×Σ→2^Q (set of possible states).)

Pushdown Automata (PDAs) Formal Definition:

A PDA is a 6 tuple P= (Q,Σ,Γ,δ,q0​,F) Σ -> input alphabet Γ -> stack alphabet δ -> Q x Σε x Γε -> P(Q x Γε ) R -> finite set of rules (rule form: V -> (V U Σ)*) S -> start variable PDA is nondeterministic

What is a Pushdown Automata?

A Pushdown Automaton (PDA) is a type of computational model that extends the capabilities of finite automata by incorporating a stack. This stack allows the PDA to manage an unbounded amount of information, making it suitable for recognizing context-free languages. Applications. Context-Free Languages: PDAs provide a theoretical foundation for context-free grammars, enabling the recognition of languages that require a stack-based memory structure.

Turing Machine - Formal Definition

A Turing Machine (TM) is a 7 tuple (Q,Σ,Γ,δ,q0​, q accept, q reject} Σ -> input alphabet Γ -> tape alphabet δ: The state transition function, which maps Q×Γ-> Q × Γ × {L, R} δ(q,a) = (r, b,R) A TM M has 3 possible outcomes for each input w: 1. Accept w (enter qaccept) 2. Reject w by halting (enter qreject) 3. Reject w by looping (running forever)

What is Turing decider?

A Turing Machine M is called a decider if it halts on all inputs, regardless of whether it accepts or rejects them. A decider TM always reaches a conclusion — it either accepts or rejects every string in the input space, without any infinite loops or indefinite running.

What is the connection between TM and DFAs?

A Turing Machine is a DFA with 2 stacks

What is Turing decidable?

A Turing decidable language has a TM (decider) that will always halt with an accept or reject decision for any input, fully determining membership in the language. A language A is Turing decidable if there exists a Turing Machine decider M such that A=L(M). This means that there's a TM that always halts and can decide membership in A for every input string. If a string is in A, the decider accepts it; if it's not in A, the decider rejects it. Therefore, Turing decidable languages are both recognized and always decided by a halting TM.

What are Turing Enumerators?

A Turing enumerator is a type of Turing Machine used to generate the strings of a language rather than deciding membership. It is designed to enumerate (or list) the strings of a language one by one. Key Features: - A Turing enumerator starts with an empty tape and repeatedly writes the next string in the language on the tape. It doesn't accept or reject inputs; instead, it generates all strings of the language in some order. - The machine may never halt, meaning it could run forever, but it will eventually generate every string in the language if given infinite time. - A language A is Turing enumerable (or recursively enumerable) if there is a Turing enumerator that can list all strings in AAA.

What is Turing-recognizable?

A Turing recognizable language has a TM that will accept strings in the language but may loop indefinitely on strings not in the language. A language A is called Turing recognizable if there exists a Turing Machine M such that A=L(M), meaning that M will accept exactly the strings in A. This means that if you give M any string w∈A, M will eventually accept w. However, if w ∉ A, M may either reject w or run indefinitely without halting. So, Turing recognizable languages may not necessarily have TMs that halt on every input.

What is a naive set?

A collection of elements

A string is ...

A finite sequence of symbols in Σ

Bijection

A function is bijective if it is both injective and surjective. This means that there is a perfect pairing between the elements of the domain and codomain. Example. Every plate must have a fork

Injective Functions (One to One)

A function is injective if different elements in the domain map to different elements in the codomain: f(a1)=f(a2)⇒a1=a2 Everything maps to a different value

Surjective Functions (Onto)

A function is surjective if every element in the codomain has at least one element in the domain that maps to it. In other words, the function covers the entire codomain: ∀b∈B,∃a∈A such that f(a)=b

A language is...

A set of strings (finite or infinite)

Subset

A set that is part of a larger set If A and B are sets, then A is a subset of B (denoted A ⊆ B) if: ∀x (x ∈ A ⇒ x ∈ B ) This means that for every element x, if x is in A, then x is also in B. If A is a subset of B, we write: A ⊆ B. If A is a subset of B, but A is not equal to B, we call it a proper subset, denoted by A ⊂ B. Example: Let's say: B = {1, 2, 3, 4} A = {1, 3} In this case, A ⊆ B, because every element of A (1 and 3) is also in B.

Empty Set

A set with no elements -> ∀x. x ∉ ∅ (For all x there does not exist an x in the empty set)

Singleton Set

A set with one element -> ∀x. ∀y x ∈ {y} <-> x = y (In all x and y, x is an element of the set containing y if and only if x is equal to y)

What is a Turing machine?

A theoretical machine to model and reason about computation. It consists of: Infinite tape: Divided into cells, each holding a symbol from a finite alphabet, acting as the machine's memory. The tape is infinite in at least one direction (to the right) Tape head: A read/write head that scans one cell at a time, can read and write symbols, and move left or right. Finite set of states: A set of states describing the machine's current status, including a start state and optional accept/reject states to indicate halting conditions. Transition function: Dictates actions based on the current state and tape symbol, determining what to write, where to move, and which state to enter next. The machine follows the transition function until it either halts or continues indefinitely.

What are ϵ-transitions?

Allows the automation to move from one states to another without consuming any input. Meaning the automation can just "jump" from one state to another, freely without reading anything for input.

What is ambiguity?

Ambiguity in context-free grammars can create confusion and uncertainty in the interpretation of generated strings. It's essential to strive for unambiguous grammars, especially in contexts like programming languages and compilers, where clear, deterministic parsing is crucial for understanding and execution. Example. G3 E -> E + E | E x E | (E) | a

If a string has two different parse trees then it is derived ambiguously and we say that the grammars is.....

Ambiguous

What does the Church-Turing thesis say?

Any real-world computation can be translated into an equivalent computation performed by a Turing machine.

Complement Set

A′= {x ∈ U ∣ x ∉ A} This means that A' consists of all elements in the universal set U that are not in A. Example: Let's define a universal set U and a set A within it: Universal set: U = {1, 2, 3, 4, 5, 6, 7, 8} Set A = {2, 4, 6} The complement of A (A') would be: A′ = {1,3,5,7,8} These are all the elements of U that are not in A.

Examples of proving Non-CF

B = { 0^k 1^k 2^k | k ≥ 0} - NOT CONTEXT-FREE because it requires the ability to count and compare three different groups of symbols, which is beyond the capabilities of a context-free grammar. F = {ww | w ∈ Σ*} Σ ={0,1} - NOT CONTEXT-FREE because it fails to satisfy the Pumping Lemma for Context-Free Languages. Recognizing an arbitrary-length duplicated substring requires more computational power than context-free grammars and pushdown automata can provide

Which of these are valid Context Free Grammars?

C1 which was: C1: S -> RR R -> 0R1 | epsilon

What is Cantor's Theorem?

Cantor's theorem, which states: For any set A, the power set P(A) has strictly greater cardinality than A itself, i.e., |A| < |P(A)|.

Closure Properties under Concatenation in NFA's.

Concatenation (A ∘ B) Definition: The concatenation of two languages A and B is the set of strings that can be formed by taking a string from A and a string from B and joining them together. NFA: If you have two NFAs, one recognizing A and the other recognizing B, you can build an NFA for A⋅B. How it works: You connect the accepting states of the first NFA (for A) to the start state of the second NFA (for B) using ϵ-transitions. This allows the NFA to finish reading a string in AA and immediately start reading a string from B, without consuming any more input.

How do you convert a CFG to a PDA

Converting a CFG to a PDA involves simulating the grammar's production rules using the stack of the PDA. The PDA manipulates the stack to replace non-terminals with their corresponding right-hand side in the productions and matches terminal symbols with the input string. This process allows the PDA to recognize the same language as the CFG.

Match the recognizer with the generator.

DFA -> Regular expression NFA, GNFA -> Regular expression PDA -> Context free grammar

Closure Properties under Kleene Star in NFA's

Definition: The Kleene star of a language A, denoted A*, is the set of strings formed by concatenating zero or more strings from A. NFA: If you have an NFA that recognizes A, you can construct an NFA that recognizes A*. How it works: You add a new start state and use an ϵ-transition from this new state to the original NFA's start state. Also, you add ϵ-transitions from the accepting states of the original NFA back to the start state to allow it to repeat. Finally, the new start state can also be an accepting state to account for the empty string (since A* includes the empty string).

All languages are regular

No

Are all context free languages regular?

No

Started with Regular Expressions -> DFA but you needed a more powerful way of dealing with languages so we used...

PDA and CFG but now we have Turing Machines

What is a relation?

R is a binary relation between A and B if R ⊆ A x B (Basically a set of pairs but not all of them) Example. R = {(2,8), (4,8), (5,10)} ⊆ {1,2,3,4,5,6,7,8,9,10,11}

What are closure properties?

Regular languages are closed under various operations, meaning that performing these operations on regular languages will always yield another regular language. This property is essential for proving that certain languages are regular and for designing algorithms and automata that work with these languages

What makes up Context Free Grammars (CFGs)?

Rule: Variable -> strings of variables and terminals Variables: Symbols appearing on the left-hand side of rule Terminals: Symbols appearing on the right-hand side Start Variable: Top Left Symbol Example. G1 S -> 0S1 S -> R R -> ε Rule: 3 rules Variables: R,S Terminals: 0,1 Start Variable: S

A language is regular if...

Some finite automation recognizes it and you can create a DFA

The pumping lemma depends on the fact that if M has p states and it runs for more than p steps then M will enter some state at least twice. We call that fact:

The Pigeonhole Principle

What can you use to prove that a language is not regular?

The Pumping Lemma

What is the Pumping Lemma?

The Pumping Lemma for Regular Languages is a tool used to prove that certain languages are non-regular. It provides a property that all regular languages must satisfy, which can help identify languages that do not follow that property. Here's a simple explanation of what it means and how it's used: What the Pumping Lemma States The Pumping Lemma states that for any regular language L, there exists a pumping length p (a positive integer) such that any string s in L with a length of at least p can be divided into three parts: s=xyz satisfying the following conditions: 1. Length Condition: ∣y∣ > 0 (the substring y is not empty). 2. Pumping Condition: The string xy^iz must be in L for all i≥0. This means that if you take the string s, and repeat y any number of times (including zero), the new string should still belong to the language L.

What is a cardinality?

The number of elements in a set

Powerset

The power set of a set A is the set of all subsets of A, including both the set itself and the empty set. For example, if A = {1, 2}, then P(A) = {∅, {1}, {2}, {1, 2}}.

Cantor's Diagonal Theorem?

The proof that R is uncountable comes from Cantor's diagonalization argument (Cantor's Diagonal Theorem) which shows that no matter how you attempt to list all the real numbers between, say, 0 and 1, there will always be a real number that is missing from the list. Therefore, R cannot be put into a one-to-one correspondence with N. The cardinality of R is denoted by c (the cardinality of the continuum) or 2^ℵ₀, which is strictly greater than ℵ₀. Thus, |R| > |N| = |Q|.

Natural Numbers -> ℕ

The set of numbers 1, 2, 3, 4, ... Also called counting numbers. {0,1,2,3,4,5,6,7........}

What is ∃?

There exists

What is a nondeterministic Turing Machine?

There may be multiple actions for a given state and symbol combination, allowing multiple "paths" of computation.

(Start of Midterm 2 material) How do you prove that a language is not Context Free?

To prove that a language is not context-free, you can use the Pumping Lemma for Context-Free Languages. This lemma provides a property that all context-free languages must satisfy, so if a language does not satisfy it, then it is not context-free. The lemma states that for any context-free language L there exists a pumping length p such that any string s ∈ L with ∣s∣ ≥ p can be split into five parts: s=uvwxy such that: 1. ∣vwx∣ ≤ p, 2. ∣vx∣ ≥ 1 (either v or x is not empty), 3. For any integer n ≥ 0, the string uv^n wx^n y is also in L. If you can find a string s ∈ L that cannot be pumped according to these rules, then L is not context-free.

Are DFAs, NFAs and Regular Expressions equivalent?

True

Is 2N and N cardinality aleph naught?

True

Regular languages are closed under union and intersection..

True Explanation. Regular languages can be recognized by finite automata (DFA/NFA), and finite automata can be combined or synchronized to handle union and intersection operations effectively. The ability to construct these combined automata shows that regular languages are closed under union and intersection.

Closure Properties under Union in NFA's.

Union (A ∪ B) Definition: The union of two languages A and B is the set of strings that belong to either A, B, or both. NFA: If you have two NFAs, one that recognizes A and one that recognizes B, you can create a new NFA that recognizes A∪B How it works: You combine the two NFAs and add a new start state. From this new start state, you have epsilon (epsilon) transitions to the start states of both original NFAs, meaning the automaton can start in either NFA without reading any input.

Regular Operations

Union -> A U B, the union of two languages and the set of strings that are either in A, B or both Concatenation -> A⋅B, taking the string A and appending it to each string from B Star (Kleene Star, *) -> A*, produces the set of all strings that can be formed by concatenating zero or more strings from A Example. Let A={a}A Then A∗={ϵ,a,aa,aaa,aaaa,...} (where ϵ is the empty string). If A={a,b} then A* would include all combinations of a and b, including the empty string.

We used the Pumping Lemma to show that D = {0^k 1^k| k ≥ 0} is not regular. How can we show that B = {w | w has equal numbers of 0s and 1s} is not regular?

We know that 0*1* is regular so B ∩ 0*1* i regular, but then D = B ∩ 0*1* and D is not regular. Therefore, B is not regular

GNFAs, NFAs, and DFAs are all equivalent, i.e. they all recognize the same class of languages

Yes, they all recognize regular languages

Are Context-Free Grammars (CFGs) and Pushdown Automata (PDAs) equivalent in terms of the languages they recognize?

Yes, this is TRUE

How do you go from a DFA to a Regular Expresssion?

You can utilize a Generalized NFA (GNFA) which involves converting a DFA into a GNFAS where transitions are labeled with regular expressions and then performing state elimination on the GNFA

How do you prove that a language is not regular?

You must give proof

How do you go from NFA to DFA?

You need the powersets and removing all ε-transitions.

What is a function?

f:A→B This means that for every element a∈A there exists exactly one element b∈B such that f(a)=b Example: Let's consider a simple function: Domain: A={1,2,3} Codomain: B={a,b,c} We can define a function f as follows: f(1)=a, f(2)=b, f(3)=c

The Pumping Lemma can be used to

prove that a language is not regular

Union Set

set that includes ALL elements of the sets entering the union; the union of sets A and B is written A U B x ∈ A U B <-> x ∈ A v x ∈ B (x is an element of A union B, if and only if there is an x that exist in A or x that exists in B) Example: if A = {1,2,3} and B = {4,5,6} , then A U B = {1,2,3,4,5,6}

Real Numbers -> ℝ

the set of all rational and irrational numbers

Intersection Set

x ∈ A ∩ B <-> x ∈ A ^ x ∈ B (x is an element of A intersection B, if and only if there is an x that exist in A and x that exists in B) Example: if A = {1,2,3,4,5} and B = {4,5,6} , then A ∩ B = {4,5}

Integers -> ℤ

{... -2, -1, 0, 1, 2, 3, 4......}

Rational Numbers -> ℚ

{..., 2/1, 2/2, 2/3, 2/4, ...} or {..., 2, 1, 0.6 ̇, 0.5, ...}

Even Numbers -> 2ℕ

{0,2,4,6,8,10......}

Which of the following languages is context free but not regular?

{0^k 1^k | k ∈ N} The language is context-free but not regular because it requires a form of memory to keep track of the number of 0s and 1s.

What statement about the cardinalities of a set A and its power set P(A) is correct? (quiz 1)

|A| < |P(A)|

What statements about the cardinalities of the set of natural numbers N = {0,1,2,3...} and the set of even natural numbers 2N = {0,2,4,6.....} is correct? (quiz 1)

|N| = |2N|

How are the cardinalities of the sets N of natural numbers, Q of rational numbers and R of real numbers related to each other? (quiz 1)

|N| = |Q| < |R|

If M1 and M2 are finite automata where M1 has k1 states and M2 has k2 states then how many states does M have?

k1 + k2 - Concatenation k1 x k2 - Union and Intersection

What is Hilbert's 10th problem?

Hilbert's 10th Problem sought an algorithm to decide if Diophantine equations have integer solutions. It was shown to be undecidable, meaning no general algorithm can solve this for all possible equations.

How do you go from a GNFA to a Regular Expression?

1. Remove one state at a time, updating the paths that go through that state. 2. Repeat until only the start and accepting states are left. 3. The transition between these two states gives you the final regular expression that describes the language accepted by the original GNFA. 4. This method helps you systematically break down complex automata into simpler expressions that capture the same language!

How do you go from Regular Expressions to NFA?

1. Start with basic symbols: Build simple NFAs for individual characters. 2. Apply union: Use ϵ-transitions to branch into different NFAs. 3. Apply concatenation: Connect NFAs in sequence using ϵ-transitions. 4. Apply Kleene star: Allow repetition with ϵ-transitions looping back to the start.

How do you read the following -> 2 ∈ {1,2,3}

2 "is an element of" the set 1,2,3

2N ⊂ N ⊂ Z ⊂ Q ⊂ R

2N⊂ N: Every element in (even natural numbers) is also an element of N because even natural numbers are natural numbers. Therefore, 2N is a subset of N. N⊂Z: Every natural number is an integer, but not every integer is a natural number. For instance, negative integers are not included in N. Hence, N is a subset of Z. Z⊂Q: Every integer can be expressed as a fraction with a denominator of 1 (e.g., 3=3/ 1​). Thus, all integers are also rational numbers, making Z a subset of Q. Q⊂R: All rational numbers are part of the real numbers, as the definition of real

If M has n states, how many states does M' have by this construction?

2^n because of the powerset construction Why? The subset construction method works by creating a DFA where each state represents a set of states in the original NFA M. Since the NFA can be in multiple states simultaneously, the DFA needs to track all possible combinations (subsets) of these states. The total number of subsets of a set of n elements (in this case, states of M) is 2^n. Therefore, M′ may have up to 2^n states. If an NFA M has n=3 states, the DFA M′ constructed from it will have states that correspond to the following subsets of M's states: Empty set ∅ {q1},{q2},{q3} (singleton sets) {q1,q2},{q1,q3},{q2,q3} (pairs of states) {q1,q2,q3} (all states) Thus, there are 2^3 =8 possible subsets, which means the DFA could have up to 8 states.

CFG Example

G2 E -> E + T | T T -> T x F | F F -> (E) | a V = {E,T,F} Σ = { +, x, (,), a} R = the 6 rules above S = E Start with the Start Symbol: E Apply the Rule E→E+T: E⇒E+T Apply the Rule E→T on the first E: E + T ⇒ T + T Apply the Rule T→F on the first T: T + T ⇒ F + T Apply the Rule F → a on the first F: F + T ⇒ a + T Apply the Rule T → T × F on the second T: a + T ⇒ a + T × F Apply the Rule T→F on the second T: a + T × F ⇒ a + F × F Apply the Rule F → a on both Fs: a + a × a

How do CFGs work?

Generating Strings: You start from the start symbol and apply the production rules to replace variables with strings of variables and terminals. This process continues until you obtain a string consisting only of terminals. CFG are also just Parse Trees

Why is B not regular? B = {w | w has equal numbers of 0s and 1s}

It is not regular because DFA's cannot count unboundedly

What is a Generalized Nondeterministic Finite Automation (GNFA)?

Is similar to a NFA but allows regular expressions as transition labels

The empty language Ø ....

Is the set with no strings

The empty string ε .....

Is the string of length 0

What is ℵ₀ (aleph-naught)?

The cardinality of any countably infinite set.


Ensembles d'études connexes

HISTORY CHAPTER 1 (Christopher Columbus)

View Set

Exam 1 - Institutional Corrections (DeShay) (TCU)

View Set

Brain & Behavior, The Minds Machine - Chapter 10 practice quiz

View Set

GI: Surgical Treatment of Liver Cirrhosis

View Set