Unit 9 - Regular Languages Flashcards

(48 cards)

1
Q

What is a mealy machine?

A

A mealy machine is a FSM which has an output determined by its current state and current input.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a state transition table?

A

A state transition table may be used to define a Mealy machine or a Turing machine. It shows all the states and possible inputs and the outputs for each combination of state and input.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a set?

A

A set is a well-defined collection of objects.
- Objects in the set are members or elements,
- A set is unordered,
- Each member in a set can only occur once,
- A set is usually denoted by a capital letter,
- A member is usually denoted by a lower case letter.
- A set can be defined by listing every member,
- A set can be defined by stating the properties held by the members, but not by the non-members,
- The members are enclosed by { } and separated by a comma.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the common sets?

A
  • N = set of natural numbers: 0, 1, 2,…
  • P = set of positive integers: 1, 2, 3,…
  • Z = set of all integers: …, -2, -1, 0, 1, 2, …
  • Q = set of rational numbers (can be expressed as a fraction)
  • R = set of real numbers

These set names may be shown as bold letters or in a special font

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the set membership expressions?

A
  • If S is a set, then the expression
    x ∈ S
    means
    “x is a member of the set S”
  • The expression
    x ∉S
    means
    “x is not a member of the set S”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the notation for set comprehension?

A
  • such that: |
  • x is a member of the set of N (natural numbers {0, 1, 2, …}): x ∈ N
  • and: ^
  • Set comprehension: S = { x | x ∈ N ᴧ x is even }
  • Compact representation: S = { x ∈ N | x is even }
  • Compact representation for strings: T = { 0n1n | n ≥ 1 } = {01, 0011, 000111, …}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are set operations?

A
  • Union: A ∪ B is the set of all members that are in A or in B,
  • Intersection: A ∩ B is the set of all members in both A and B,
  • Difference: A \ B is the set of all members that are in A but not in B.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How might the empty set be represented?

A

{} or ø

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the rules for subsets?

A
  • A is a subset of B, when every member of A is also a member of B:
  • A ⊆ B
  • A is not a subset of B, if at least one member of A does not belong to B :
  • A ⊈ B
  • A is a proper subset of B, when A is a subset of B but A ≠ B:
  • A ⊂ B
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the cartesian product of two sets?

A

The Cartesian product of two sets A and B is the set of all ordered pairs (a, b), such that a ∈ A and b ∈ B
Cartesian product notation: A x B, read as “A cross B”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a finite set?

A

A finite set contains an exact number of distinct members where number ∈ N.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the cardinality of a set?

A

The cardinality of a finite set is the number of members in the set.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is an infinite set?

A

An infinite set contains an infinite number of distinct members.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a regular expressions?

A

Regular expressions are patterns used to specify a set of strings.
- A simple way of describing a set,
- A way of describing some types of languages using a shorthand notation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a countably infinite set?

A

A countably infinite set is one whose members can be counted using the infinite set N.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the notation rules for regular expressions?

A
  • Members side-by-side must appear in that sequence,
  • | : Separates alternatives (or, ⋁),
  • asterisk : Indicates that there are zero or more of the preceding element,
  • plus : Indicates that there are one or more of the preceding element,
  • ? : Indicates that there are zero or one of the preceding element,
  • () : Used to identify groupings.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a regular language?

A

A language is regular if it can be represented by a regular expression or finite state machine (FSM).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is a Turing machine?

A

A Turing machine is a theoretical machine, rather than a physical object, thought up by Turing in 1936 which can simulate ANY computer algorithm, no matter how complex.

A Turing Machine consists of two parts: the tape that the machine can read and write, and the controller (the program) determines what happens at each cell.
- It has a read-write head that can read symbols from the tape,
- The tape is infinitely long, with marked-off squares,
- The machine must have at least one state, the halting state, that causes it to halt for some inputs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is a controller?

A

The “controller” is a finite state machine which tells a Turing machine what to do next.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is a transition function?

A

A transition function is a way to represent the transition arc between two states on a state transition diagram.
- The symbol δ is the lower case Greek letter delta: it means a small change
- Each transition arc on a state transition diagram can be represented by the δ function using a pattern:
δ (Current state, Input symbol) = (Next state, Output symbol, Head move)

20
Q

Why is the Turing Machine important?

A
  • It provides a definition of what is computable,
  • It can be proven mathematically that a Turing Machine is capable of computing anything that is computable,
  • The mathematical definition of a Turing machine defines what is computable.
21
Q

What is a Universal Turing Machine?

A

A Universal Turing Machine simulates the behaviour of any Turing machine by reading the definition of a Turing machine and the input data.
This led to the idea of the stored program computer and specifically Von Neumann architecture.

22
Q

Why is the Universal Turing Machine important?

A
  • It provides a definition of what is computable,
  • It can be proven mathematically that a Universal Turing Machine is capable of computing anything that is computable.
23
Q

What are the four characteristics of a Turing machine?

A
  1. A finite set of states,
  2. A finite alphabet of symbols,
  3. An infinite tape, marked off in squares,
  4. A read-write head that can move left and right one square at a time.
24
What is the relationship between a transition function and a state transition diagram?
The transition function can be used to produce the same rules for transitions as illustrated on a state transition diagram. This provides for a more compact definition which can be manipulated mathematically.
25
Why can a Universal Turing machine can be considered an interpreter?
Because a UTM simulates the behaviour of a TM. A UTM interprets the definition of the TM (its transition functions) and applies them to the TM’s input.
26
What is Backus-Naur Form?
Backus-Naur Form (BNF) is the formal notation used to describe the syntax rules of a language, it’s a meta-language: A language that describes a language.
27
Why do we need BNF?
Regular languages are expressible by regular expressions, but some languages cannot be expressed by a regular expression. The class of languages called context-free languages is more expressive than regular languages. BNF is a way to define these context-free languages.
28
What are the BNF meta-symbols?
- ::= : Is defined as, - | : OR, - < > : Surrounds category names, - Side by side: Items must follow exactly, - Terminal symbols: Cannot be further broken down, - Non-terminal symbols: Can be further broken down.
29
How can a context free language be defined by BNF?
A context-free language can be defined by BNF when a single non-terminal symbol on the left can always be replaced by the definition on the right.
30
What is a production rule?
Each individual BNF statement is called a ‘production rule’.
31
What is a recursive rule?
A recursive rule is defined in terms of itself.
32
What is parsing?
The act of parsing is checking an input string against the set of BNF rules to see if it is valid.
33
What is a parse tree?
A graphical way to represent parsing.
34
What is a syntax diagram?
Another way to represent context-free languages, it is the graphical equivalent of BNF.
35
What is Prefix notation?
The operator comes before the operands. Also known as Polish notation. / * a + b c d [Infix: a * (b + c) / d]
36
What is Infix notation?
The operator comes between the operands. This is the notation used in the mathematics you’ve encountered before . a * (b + c) / d
37
What is Postfix notation?
The operator comes after the operands. Also known as Reverse Polish notation. a b c + * d / [Infix: a * (b + c) / d]
38
Why was Reverse Polish notation (RPN) / Postfix notation invented?
Reverse Polish was devised as a way to do mathematics without braces. The system is used extensively in computer algorithms because evaluation can be done using a stack.
39
Why use Reverse Polish notation (RPN) / Postfix notation?
- Eliminates the need for brackets in sub-expressions, - The resulting expressions can be evaluated using a stack (more later), - Used in interpreters based on a stack.
40
What is the arithmetic order of precedence?
1. ~ - unary minus, 2. ^ - exponentiation, 3. * / - multiplication and division, 4. + - - addition and subtraction, 5. = - equals
41
What are the ways to convert from infix to RPN?
- Translation by numbering, - Translation by bracketing, - Translation by binary tree.
42
What are the ways to convert from RPN to infix?
- Translation by scanning, - Translation by bracketing.
43
How does Translation by numbering work?
This algorithm works by numbering operands and operators: 1) Start on left, with the number 1, 2) If the token is an operand, allocate the next number, 3) Ignore brackets except in so far as they affect the order of calculation, 4) If it is an operator, and enough operands are available, then back up and number the operator, otherwise advance to next token, 5) Keep order of precedence in mind, as it might require some reading ahead, 6) When finished, write down the tokens in numerical order.
44
How does Translation by bracketing (Infix to RPN) work?
This method works by fully bracketing the expression and rearranging the operators inside the brackets: 1) Add brackets to fully enforce order of precedence, including exponentiation, 2) Move the operator in each set of brackets to the end position, 3) Remove all the brackets.
45
How does Translation by binary tree work?
This method works by building a binary tree from the infix expression and then traversing it using a post-order traversal algorithm. e.g. a * (b + c) / d 1) Decompose operands into two child nodes; pay attention to precedence and brackets, 2) Repeat these two steps until you have a tree.
46
How does Translation by Scanning work?
This method works by scanning left to right, picking out pairs of operands and single operators: 1) Scan right, writing down operands, 2) If you find an operator, check if you have already written operands where it can be inserted, 3) If inserting an operator, add brackets
47
How does Translation by bracketing (RPN to Infix) work?
This method works by adding brackets to enforce order of execution, then moving operators between operands. 1) Insert brackets as indicated by operators, 2) Move operators between closest operands, 3) Remove excess brackets.