4.2 regular languages

0.0(0)
studied byStudied by 1 person
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/30

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

31 Terms

1
New cards

regular languages

sets of strings which can be defined by finite state machines and regular expressions

2
New cards

finite state machines

an abstract mathematical model of computation with a finite set of states and rules defining how it transitions through these states

used to describe simple algorithms

3
New cards

state transition diagrams

diagrams representing FSMs with:

-states as circles labelled Sn

S0 is the start state

a double-outlined circle is the stop state

stop states can be left if an arrow is pointing out

-arrows leading from one state to another (or from a state to itself)

-arrows are labelled with the input that cause the corresponding state change

-inputs may be paired to outputs with | separating them

<p>diagrams representing FSMs with:</p><p>-states as circles labelled Sn</p><p>S0 is the start state</p><p>a double-outlined circle is the stop state</p><p>stop states can be left if an arrow is pointing out</p><p>-arrows leading from one state to another (or from a state to itself)</p><p>-arrows are labelled with the input that cause the corresponding state change</p><p>-inputs may be paired to outputs with | separating them</p>
4
New cards

set

an abstract data type containing unordered unique values (values can be other sets)

notated as S : {item, item, item}

5
New cards

set comprehension

a method of creating a set by specifying rules rather than the individual values

[name] = { [formula in relation to x] | x ∈ [set] ∧ [bounds of x] (optional: ∧ [second bound of x]) }

e.x. S={x*3|x∈ℤ ∧ x≥-3 ∧ x<3}

6
New cards

empty set notation

{} or Ø

7
New cards

compact set representation

highly compact ways of describing sets with simple rules

e.x. {0^n1^n | n > 0}

describes 01, 0011, 000111 etc

8
New cards

finite sets

sets with a finite number of items, the cardinality of a finite set refers to the number of elements within it

9
New cards

infinite sets

sets with an infinite number of items, can be countably or non-countably infinite

10
New cards

countably infinite sets

sets that could theoretically be listed in a logical order given infinite time

11
New cards

non-countable infinite sets

sets that could not be theoretically listed in a logical order given infinite time

12
New cards

countable vs non-countable infinite sets

countable:

natural numbers and integers, as they follow a clear order (even though integers can’t be listed in order of magnitude, they can be listed as 0, 1, -1 etc)

rational numbers, as they can be written as fractions with integers on either side, and can thus be listed in a logical pattern even if they would be impossible to order in terms of magnitude (method of doing this is long to explain and isn’t required knowledge for the exam)

non-countable:

real numbers, as many recur infinitely so could never be listed even given infinite time, and there is no logical pattern in which they could be ordered

13
New cards

subset

a set is a subset of another set if it only contains items present in that set

notated as subset ⊆ set

14
New cards

proper subset

a set is a proper subset of another set if it only contains items present in that set, AND it does not contain all of the items present in that set

15
New cards

countable sets

all finite sets, and all countably infinite sets

16
New cards

membership

an item’s presence in a set

denoted as item ∈ set

lack of membership is denotes as item ∉ set

17
New cards

set operations

operations allowing sets to be constructed from other sets using three operations: union, intersection and difference

18
New cards

union

set1 ∪ set2

creates a set with all values from the sets

19
New cards

intersection

set1 ∩ set2

creates a set with only values present in both of the sets

20
New cards

difference

set1\set2 or set1 - set2

creates a set with values present in set1 but not in set2

21
New cards

regular expressions

shorthand ways of describing sets using metacharacters ( * + ? and | )

22
New cards

*

metacharacter describing 0 or more repetitions of the previous character

e.x. ab* matches to {a, ab, abb … }

23
New cards

+

metacharacter describing 1 or more repetitions of the previous character

e.x. ab+ matches to {ab, abb, abbb … }

24
New cards

?

metacharacter describing 0-1 repetitions of the previous character

e.x. colou?r matches to {colour, color}

25
New cards

|

metacharacter describing an instance of either the character before or after

e.x. a|b matches to {a, b}

26
New cards

()

used to group multiple characters as one in regular expressions

e.x. a(bc)* matches to {a, abc, abcbc … }

a(bc)+ matches to {abc, abcbc, abcbcbc … }

abc(de)? matches to {abc, abcde}

(ab)|(bc) matches to {ab, bc}

27
New cards

expressing regular expressions as finite state machines

-the input string is read by the FSM character-by-character

-when the FSM has halted, the string produced is deemed as valid for the corresponding regular language

-if it cannot halt, the input is deemed as invalid

(ie if it FSM is stuck in a non-halting state which it cannot transition out of, or if a read character does not have a corresponding transition)

28
New cards

* in a FSM

creates a self-transition corresponding to the character before the *

if multiple characters are included before the * in brackets, each character transitions to a new state until the last character which transitions back onto the original state, forming a loop

29
New cards

+ in a FSM

creates a transition corresponding to the character before the + to another state, which has a self-transition for further occurrences of the character

if multiple characters are included before the + in brackets, each character transitions to a new state, then the state for the last character has a transition triggered by the first character, leading back onto the state for the first character

30
New cards

? in a FSM

creates one transition to a new state for the character

if multiple characters are included before the ? in brackets, each character contains a transition to a new state

31
New cards

| in a FSM

creates one transition for each option leading to the same state

if multiple characters are included on either side of the | in brackets, each character on that side contains a transition to a new state until the last character which transitions to the shared state