ALC-Prac-10A.pdf
MAT2ALC Practice Class 10A Turing Machines (TM)
1. Below is a doubling machine (see Example 9.2.2 in NGV). It has input
alphabet {0} and tape alphabet {0,a,2} and implements the string
function f : 0∗ → 0∗ defined by f(0n) = 02n.
q0 q1
q2q3
0 7→ (a,L)
2 7→ (0,R)
a 7→ (0,R)
2 7→ (2,L)
(0 7→ (0,L)
(0 7→ (0,R)
(a) Write down the transition table for this Turing machine.
(b) (i) Complete the following configuration notation description
(q0, 00) → (q1,2a0) → (q2, 0a0) → . . .
of the processing of the word 00.
(ii) How many “moves” were required to do the computation in (i)?
(Count the arrows in the configuration notation.)
(c) Suppose the machine is processing the word 0n for some n ≥ 1.
(i) What is on the tape when the machine first reaches state q2?
(Don’t forget to underline of the read/write cell.)
(ii) What is on the tape the second time the machine reaches q2?
(iii) What is on the tape the next time the machine reaches q2?
(iv) What is on the tape the last time the machine reaches q2?
(v) What is on the tape the last time the machine reaches q0?
(vi) Which state is the machine in when processing halts?
(d) Use configuration notation to discover what happens if this machine
is started with only blanks on the tape, so the initial configuration
looks something like (q0,222).
2. In this question we design a TM with input alphabet Σ = {0, 1} and
alphabet Γ = {0, 1,2} that adds 1 to a binary number x written in the
usual way on the tape. We will develop a machine by tackling one task
at a time.
(a) On paper, add 1 to the binary numbers 110, 101, 1001 and 111.
Does this suggest a simple algorithm for adding 1 to x?
(b) When adding 1 to x we start at the right most digit. Design a TM
with two states that moves to the last digit of x and halts in an
accepting state. (Move right until a blank is found and then move
left once.)
(c) (i) What is the effect of adding 1 to a binary number with last
digit 0?
(ii) Extend the machine of (a) to one that adds 1 if x ends with 0
and (for now) rejects x if it ends with 1.
(d) (i) When we add 1 to a number with final digit 1, what happens
to the final digit?
(ii) Extend the machine to one that gives the correct final digit 1
when x ends with 1 and moves to a new “carry” state C.
(e) (i) By adding 1 to the binary number 1011, decide how the ma-
chine should behave when it is in state C.
(ii) Add transitions to the machine that implement this.
(f) (i) Does the machine work correctly if all digits in x are 1?
(ii) Add a transition to the machine that rectifies this.
3. The strategy of the TM of Question 1 is to place a marker a at the left
of the input word and move it to the left as new 0’s are added at the left
of the tape contents. The following machine attempts to modify this
strategy by again placing a marker a at the left of the input and moving
it to the right as new 0’s are added on the right of the tape contents.
q0 q1 q2 q3
0 7→ (a,R) 2 7→ (0,L) 2 7→ (2,L.
ALC-Prac-10A.pdfMAT2ALC Practice Class 10A Turing Machines.docx
1. ALC-Prac-10A.pdf
MAT2ALC Practice Class 10A Turing Machines (TM)
1. Below is a doubling machine (see Example 9.2.2 in NGV). It
has input
alphabet {0} and tape alphabet {0,a,2} and implements the
string
function f : 0∗ → 0∗ defined by f(0n) = 02n.
q0 q1
q2q3
0 7→ (a,L)
2 7→ (0,R)
a 7→ (0,R)
2 7→ (2,L)
(0 7→ (0,L)
(0 7→ (0,R)
(a) Write down the transition table for this Turing machine.
(b) (i) Complete the following configuration notation
description
(q0, 00) → (q1,2a0) → (q2, 0a0) → . . .
2. of the processing of the word 00.
(ii) How many “moves” were required to do the computation in
(i)?
(Count the arrows in the configuration notation.)
(c) Suppose the machine is processing the word 0n for some n ≥
1.
(i) What is on the tape when the machine first reaches state q2?
(Don’t forget to underline of the read/write cell.)
(ii) What is on the tape the second time the machine reaches q2?
(iii) What is on the tape the next time the machine reaches q2?
(iv) What is on the tape the last time the machine reaches q2?
(v) What is on the tape the last time the machine reaches q0?
(vi) Which state is the machine in when processing halts?
(d) Use configuration notation to discover what happens if this
machine
is started with only blanks on the tape, so the initial
configuration
looks something like (q0,222).
2. In this question we design a TM with input alphabet Σ = {0,
1} and
alphabet Γ = {0, 1,2} that adds 1 to a binary number x written
in the
usual way on the tape. We will develop a machine by tackling
one task
at a time.
3. (a) On paper, add 1 to the binary numbers 110, 101, 1001 and
111.
Does this suggest a simple algorithm for adding 1 to x?
(b) When adding 1 to x we start at the right most digit. Design a
TM
with two states that moves to the last digit of x and halts in an
accepting state. (Move right until a blank is found and then
move
left once.)
(c) (i) What is the effect of adding 1 to a binary number with
last
digit 0?
(ii) Extend the machine of (a) to one that adds 1 if x ends with 0
and (for now) rejects x if it ends with 1.
(d) (i) When we add 1 to a number with final digit 1, what
happens
to the final digit?
(ii) Extend the machine to one that gives the correct final digit
1
when x ends with 1 and moves to a new “carry” state C.
(e) (i) By adding 1 to the binary number 1011, decide how the
ma-
chine should behave when it is in state C.
(ii) Add transitions to the machine that implement this.
(f) (i) Does the machine work correctly if all digits in x are 1?
(ii) Add a transition to the machine that rectifies this.
4. 3. The strategy of the TM of Question 1 is to place a marker a at
the left
of the input word and move it to the left as new 0’s are added at
the left
of the tape contents. The following machine attempts to modify
this
strategy by again placing a marker a at the left of the input and
moving
it to the right as new 0’s are added on the right of the tape
contents.
q0 q1 q2 q3
0 7→ (a,R) 2 7→ (0,L) 2 7→ (2,L)
a 7→ (0,R)
(0 7→ (0,R) (0 7→ (0,L)
(a) Use configuration notation to show the first 8 moves this
machine
makes when trying to process the word 0.
(b) Will this machine ever halt when given the input word 0?
(c) Will this machine ever halt given the input word 0n for n ≥
1?
1
Simulating a finite state recognition machine.
Given the directed graph of a finite state recognition machine,
we can
construct a Turing machine recognizing the same language as
5. follows.
• Replace each existing edge label a by a 7→ (a,R).
• Add a new accepting state Z.
• For each existing accepting state q, add an arrow from q 7→ Z
labeled 2 → (2,L).
• Change all previously accepting states to non-accepting states.
4. (a) Draw the graph of a Turing machine recognizing the same
language
as the finite state recognition machine shown below.
σ
A B
C D
Z
σ
A B
C D
0
0, 1
1
0
1
6. (b) Check that the words 01 and 10111 are accepted by both
machines
using the relevant configuration notations.
(c) Check that the words 010 and 1010 are rejected by both
machines
using the relevant configuration notations.
Pumping lemma for context free languages.
For any context free language L, there is a special number p ∈
N (called
a pumping length) such that any word w ∈ L for which |w| ≥ p
can
be written as w = uvxyz where
(a) |vxy| ≤ p,
(b) v 6= ε or y 6= ε (i.e. at least one of v and y is non-empty),
(c) The word uvixyiz is in L for every i ≥ 0.
The pumping lemma is used to show certain languages are not
context
free.
5. In this question we use the pumping lemma to show
L = {0q : q is prime} = {w ∈ {0}∗ : |w| is prime}
is not context free. We employ the proof by contradiction
technique, so
we start by assuming that L is context free. The pumping lemma
then
gives a pumping length p and we choose a prime q ≥ p, so that
7. the word
0q ∈ L can be written 0q = uvxyz as in the Lemma.
(a) Use the fact that v = 0j and y = 0k for some j,k ≥ 0 to
complete
the calculation
w = uvq+1xyq+1z = uvxyzvqyq = 0qvqyq . . .
and hence calculate |w|.
(b) What does part (b) of the Lemma tell us about j + k?
(c) Note that w ∈ L by part (c) of the Lemma, so |w| is prime.
Use
the results of (a) and (b) above to show |w| is not prime, thus
giving a contradiction.
6. (a) Adapt the argument of Example 9.1.2 to show the
following lan-
guage is not context free.
L = {0n
2
: n ≥ 0} = {w ∈ {0}∗ : (∃ m ≥ 0) |w| = m2}
(b) Do you know of an easier way to prove L is not context
free?
2
ALC-Prac-10A-solutions.pdf
MAT2ALC Answers to Practice Class 10A
8. 1. (a) x 0 a 2
δ(x,q0) (a,q1,L) ∅ (2,q3,L)
δ(x,q1) (0,q1,L) ∅ (0,q2,R)
δ(x,q2) (0,q2,R) (0,q0,R) ∅
(b) (i) (q0,00) → (q1,2a0) → (q2,0a0) → (q0,000) → (q1,00a)
→ (q1,00a) → (q1,200a) → (q2,000a) → (q2,000a)
→ (q2,000a) → (q0,00002) → (q3,0000) (accept).
(ii) 11.
(c) (i) 0a0n−1.
(ii) 000a0n−2.
(iii) 00000a0n−3.
(iv) 0002n−3a.
(v) 02n2.
(vi) q3.
(d) (q0,222) → (q3,222) (accept).
2. (a) 110+1 = 111,101+1 = 110,1001+1 = 1010 and 111+1 =
1000.
Algorithm:
• Go to right of input word and start moving leftward.
• While input symbols are all 1’s change them to 0’s.
• When a 0 is encountered, change it to 1 and stop.
• If 0 has not been encountered when leftmost symbol is
reached,
9. write a 1 to the left of it.
(b)
q0 q1
1 7→ (1,R),
0 7→ (0,R)
2 7→ (2,L)
(c) (i) The last digit 0 becomes 1. Other digits are not altered.
(ii)
q0 q1 q2
1 7→ (1,R),
0 7→ (0,R)
2 7→ (2,L) 0 7→ (1,L)
(d) (i) The final digit becomes 0.
(ii)
q0 q1
C
q2
1 7→ (1,R),
0 7→ (0,R)
10. 2 7→ (2,L)
1 7→ (0,L)
0 7→ (1,L)
(e) (i) Machine should move left changing 1’s to 0’s until a 0 is
en-
countered and then change that 0 to 1.
(ii)
q0 q1
C
q2
1 7→ (1,R),
0 7→ (0,R)
2 7→ (2,L)
1 7→ (0,L)
0 7→ (1,L)
0 7→ (1,L)
1 7→ (0,L)
(f) (i) No. It encounters a 2 at C. This transition is undefined.
(ii)
q0 q1
12. A B
C D
Z
0 7→ (0,R)
0 7→ (0,R),
1 7→ (1,R)
1 7→ (1,R)
2 7→ (2,L)
2 7→ (2,L)
0 7→ (0,R)
1 7→ (1,R)
(b) For FSM: σ
0→ A 1→ B and σ 1→ C 0→ D 1→ D 1→ D 1→ D (both
accepted).
For Turing Machine: (σ,01) → (A,01) → (B,012) → (Z,01) and
(σ,10111) → (C,10111) → (D,10111) → (D,10111) →
(D,10111)
→ (D,101112) → (Z,10111)
(both accepted).
(c) FSM: σ
0→ A 1→ B 0→ ∅ and σ 1→ C 0→ D 1→ D 0→ ∅ (both
13. rejected).
For Turing Machine: (σ,010) → (A,010) → (B,010) → ∅ and
(σ,1010) → (C,1010) → (D,1010) → (D,1010) → ∅ (both
rejected).
5. (a) w =uvq+1xyq+1z = uvxyzvqyq = 0qvqyq = 0q(0j)q(0k)q
= 0q0jq0kq = 0q+jq+kq = 0q(1+j+k)
and hence |w| = q(1 + j + k).
(b) j + k ≥ 1.
(c) By (b) we have 1 + j + k > 1 and q > 1 since q is prime. But
by
(a) |w| = q(1+j +k) which is not prime because it is a product of
two natural numbers greater than 1. Since this is a
contradiction,
we conclude that L is not context free.
6. (a) Suppose L = {0n
2
: n ≥ 0} = {w ∈ {0}∗ : (∃ m ≥ 0) |w| = m2}
is context free. Pick any n ≥ p where p is the pumping length for
L. By definition w = 0n
2
∈ L and |w| = n2 ≥ p so the pumping
lemma gives w = uvxyz where |vxy| ≤ p and at least one of v
and
y is non-empty. Now v = 0j or y = 0k for some 0 ≤ j,k ≤ n2. The
fact that at least one of v = 0j and y = 0k is non-empty means
that j + k ≥ 1 and the fact that |vxy| ≤ p means j + k ≤ p ≤ n.
14. The “pumped up” word
s = uv2xy2z = u0j0jx0k0kz = u02jx02kz
is also in L and it is easy to see that |s| = |w|+j +k = n2 +j +k.
Since s ∈ L there must be an m such that |s| = m2 and since
|s| = n2 + j + k > n2 we must have |s| ≥ (n + 1)2. Hence
|s| = n2 + j + k ≥ (n + 1)2 = n2 + 2n + 1
=⇒ n2 + j + k ≥ n2 + 2n + 1
=⇒ j + k ≥ 2n + 1
=⇒ 2n + 1 ≤ j + k.
But this is impossible! We just showed j + k ≤ n, so transitivity
of ≤ gives 2n + 1 ≤ n which is can’t happen because n ≥ p ≥ 1.
Since our original assumption led us to a contradiction, we
conclude
that L is not context free.
(b) By Theorem 9.2, we only need to show L is not regular. This
can
be done by showing it has infinitely many suffix sets.
2
ALC-Prac-10B.pdf
MAT2ALC Practice Class 10B
Classification of Groups into Isomorphism Classes
Question 1. Draw up a table with 2 columns, one headed
isomorphism class and the other headed
15. distinguishing property. Then classify the groups listed below
into isomorphism classes by filling up
the table. Each isomorphism class should be a list of groups
which are isomorphic to each other but not
isomorphic to any other groups in the list.
For example, if you believe that Z6 is isomorphic to Symm(4)
because they are both of order 6 and
if you think that no other given group is of order 6 then one line
should be
Isomorphism Class Distinguishing Property
Z6, Symm(4) of order 6
WARNING: this isn’t correct!
[HINT. First find the order of each group, then work from
smallest to largest.]
Question 2 There are exactly 6 classes which contain more than
one group. For each of these classes,
explain carefully why all the groups in the class are isomorphic
to one another.
Some Useful Results
10.13 The Prime Order Theorem Let p be prime. Up to
isomorphism, there is only one group
G of order p. Indeed, if |G| = p, then G ∼= Zp.
10.19 Products of Cyclic Groups Theorem (Second Version)
16. (i) Zm ×Zn ∼= Zmn if and only if m and n are relatively prime.
(ii) Zm1 ×Zm2 ×···×Zmn ∼= Zm1m2···mn if and only if m1,
m2, . . . , mn are pairwise relatively
prime.
10.25 The Groups of Order Four Theorem Up to isomorphism,
there are only two groups of
order 4. Indeed, for any group G with |G| = 4,
• if G satisfies (∃ x) x2 6= e, then G ∼= Z4, and
• if G satisfies (∀ x) x2 = e, then G ∼= Klein4 ∼= U8.
10.26 The Groups of Order Six Theorem Up to isomorphism,
there are only two groups of
order 6. Indeed, for any group G with |G| = 6,
• if G is abelian, then G ∼= Z6, and
• if G is not abelian, then G ∼= Symm(4).
(In the following list, Sn denotes the group of all permutations
of {1, 2, . . . , n}.)
LIST OF GROUPS
(a) Symm(4) = S3
(b) G1 := ({2, 4, 8};⊗14)
(c) Symm(�)
(d) (U7;⊗7)
(e) (Z6;⊕6)
(f) G2 := {g2 | g ∈ Symm(4)}6 Symm(4)
(g) (Z4;⊕4)
(h) Klein4
(i) (U4;⊗4)
(j) (Z8;⊕8)
(k) Z2 ×Z3
17. (l) (Z12;⊕12)
(m) Symm(6-gon) 6 S6
(n) Symm(Tetra) 6 S4
(o) G3 := ({ id, a, b, c, d, e};∗ ) given by the table
* id a b c d e
id id a b c d e
a a id c e b d
b b d e a c id
c c b d id e a
d d e a b id c
e e c id d a b
(p) G4 := {id, (12), (34), (12)(34)}6 S4
(q) Z2 ×Z6
(r) G5 := (Z4;∗ ), where a∗ b := a⊕4 b⊕4 2
(s) Z3 ×Z4
(t) Z2 ×Z4
1
ALC-Prac-10B-solutions.pdf
MAT2ALC Model Answers to Practice Class 10B
1. The information in the table given in round brackets is not
needed. (It is given as additional infor-
18. mation for the reader.)
Isomorphism Class Distinguishing Property
U4 order 2 ( & cyclic)
G1, G2 order 3 ( & cyclic)
Z4, G5 order 4 & (∃ x) x2 6= e [or order 4 & cyclic (and
therefore abelian)]
Klein4, G4 order 4 & (∀ x) x2 = e (and therefore noncyclic)
Symm(4), G3 order 6 & nonabelian
Z6, U7, Z2 ×Z3 order 6 & abelian (in fact, cyclic)
Symm(�) order 8 & nonabelian
Z8 order 8 & cyclic (and therefore abelian)
Z2 ×Z4 order 8 & abelian & (∀ x) x4 = e (and therefore
noncyclic)
Z12, Z3 ×Z4 order 12 & cyclic (and therefore abelian)
Symm(6-gon) order 12 & nonabelian & (∃ x) O(x) = 6
Symm(Tetra) order 12 & nonabelian & (∀ x) O(x) 6= 6
Z2 ×Z6 order 12 & abelian & (∀ x) x6 = e (and therefore
noncyclic)
2. (a) |G1| = |G2| = 3. Since 3 is prime, by the Prime Order
Theorem 10.13 both G1 and G2 are isomorphic
to Z3 and are therefore isomorphic to each other.
(b) By the Groups of Order Four Theorem 10.25, up to
isomorphism there are only two groups G of
order 4: if G satisfies (∀ x) x2 = e, then G ∼= Klein4 and if G
satisfies (∃ x) x2 6= e, then G ∼= Z4.
(i) For G5 we have |G5| = 4, the identity element is 2 (either
19. look at the formula for a ∗ b or draw
up the table for ∗ ) and 12 = 1 ∗ 1 = 0 6= 2, so G5 satisfies
(∃ x) x2 6= e. Hence G5 ∼= Z4.
(ii) We have |G4| = 4 and since id2 = (1 2)2 = (3 4)2 = ((1 2)(3
4))2 = id, the group G4 satisfies
(∀ x) x2 = e. Thus G4 ∼= Klein4.
(c) By the Groups of Order Six Theorem 10.26, up to
isomorphism there are only two groups G of order 6:
if G is abelian, then G ∼= Z6, and if G is not abelian, then G
∼= Symm(4).
(i) |G3| = 6 and G3 is not abelian since ab = c, while ba = d.
Thus G3 ∼= Symm(4).
(ii) U7 = {1, 2, 3, 4, 5, 6} and hence |U7| = 6. Since (U7,⊗7) is
abelian (as ⊗7 is a commutative
operation), we have U7 ∼= Z6.
(iii) Since 2 and 3 are relatively prime, Z2×Z3 ∼= Z6 by the
Products of Cyclic Groups Theorem 10.19.
[Alternatively, |Z2×Z3| = |Z2|×|Z3| = 6 and Z2×Z3 is abelian
since both Z2 and Z3 are abelian
(see Lemma 6.6). Hence Z2 ×Z3 ∼= Z6.]
(d) Since 3 and 4 are relatively prime, Z3 ×Z4 ∼= Z12, by the
Products of Cyclic Groups Theorem 10.19.
1
ALC-Prac-11A.pdf
20. MAT2ALC Practice Class 11A Turing Machines (TM)
Does it halt?
Consider the Turing Machine S (for Surprise), with tape
alphabet Γ = {2, 1, 2}, set of states Q =
{q1,q2,q3}. The transition table for S is given below:
x 2 1 2
δ(x,q1) (1,q2,R) (2,q2,L) (1,q3,L)
δ(x,q2) (1,q1,L) (2,q2,R) (1,q2,R)
δ(x,q3) ∅ (2,q1,L) (2,q3,L)
Notice that the initial state has not been specified. In each of
the three questions below, it will be
different.
1. Let S3 be the machine S with q3 as the initial state. Does S3
halt when started on blank tape?
2. Let S2 be the machine S with q2 as the initial state. Does S2
halt when started on blank
tape? Draw the directed graph representation, if you think it can
help, and use the configuration
notation, to “run” S2. Be careful and patient!
3. Let S1 be the machine S with q1 as the initial state. Does S1
halt when started on blank tape?
Before you start running S1, let Charles/Stacey/Tomasz know.
4. Design a Turing Machine that does not halt when run on
blank tape, but does halt when run on
any non-blank tape. You can use as many states and symbols as
you like, but you do not need
too many.
21. 5. Design a Turing Machine R (for Reverter) with tape alphabet
Γ = {2, 0, 1}, and as many states
as you like, which does the following.
(a) When run on tape containing precisely one 1 and blank
otherwise, it halts scanning a blank
to the left of a single 0 on an otherwise blank tape.
(b) When run on tape containing precisely one 0 and blank
otherwise, it halts scanning a blank
to the left of a single 1 on an otherwise blank tape.
(c) When run on any other input, R can do anything whatever.
To be precise: it is not important
what R does then.
1
ALC-Prac-11A-solutions.pdf
MAT2ALC Answers to Practice Class 11A
The graph representation of S is
q1q2 q3
2 7→ (1, L)
1 7→ (2, L)1 7→ (2, L)
2 7→ (1, R)
2 7→ (1, L)
2 7→ (1, R)
1 7→ (2, R) 2 7→ (2, L)
22. 1. When started on a blank tape in state q3 the machine halts
immediately, as there is no transition
defined for 2.
2. When started on a blank tape in state q2 the machine halts
after 83 steps. If you are careful and
patient you could verify this by hand. Alternatively, you could
use a Turing machine simulator. For
example, morphett.info/turing/turing.html
3. When started on a blank tape in state q2 the machine halts
after 2,315,619 steps. Using
morphett.info/turing/turing.html on a rather old PC running
Linux, it took about 2h 30min to
verify.
There are many correct solutions to 4 and 5. The ones given
below are just examples.
4. For example
q0 2 7→ (2, R)
5. For example
q0
1 7→ (0, L)
0 7→ (1, L)
In the configuration notation, the operations of the machine on
inputs of the required type, are:
• (q0, 0) → (q0, 21) → halt, and
• (q0, 1) → (q0, 20) → halt.
23. 1
ALC-Prac-11B.pdf
MAT2ALC Practice Class 11B
Equivalence Relations, Partitions and Cosets
Try to do the exercises below based on what you saw in the
lecture. If
you are unsure, you will find a reference in square brackets to a
relevant
fact from the text.
1. Consider the group (Z12;⊕12) and the subgroup H := {0, 4,
8}.
(a) Calculate the left coset 1 ⊕12 H. [See Definition 11.12]
(b) Choose any element a ∈ 1 ⊕12 H with a 6= 1. Calculate
a⊕12 H.
(c) True or false: a⊕12 H = 1 ⊕12 H?
2. Assume that a⊕15 H = {4, 9, 14} is a left coset of a subgroup
H of (Z15;⊕15).
(a) Write down H and the smallest possible value for a.
H = {...............................................................}, a = .......
(b) The number of distinct left cosets of H in Z15 is ..............
[See 11.23, the Number of Cosets.]
(c) Give two different names, other than that in (a), for the
coset a⊕15 H above.
24. a⊕15 H = ....... ⊕15 H = ....... ⊕15 H.
[See the Coset Equality Lemma 11.17.]
3. Consider the group Symm(4) and its subgroup H := {id, (1
2)}.
(a) How many distinct left cosets does H have in Symm(4)?
(b) Use the Coset Algorithm 11.19 to find the distinct left
cosets of H in (Symm(4);◦).
[See Example 11.20.]
4. (a) Consider the group (Z12;⊕12) and the subgroup H := {0,
4, 8}.
(i) How many distinct left cosets does H have in Z12?
(ii) Use the Coset Algorithm 10.12 to find the distinct left
cosets of H in (Z12;⊕12).
(b) Define ϕ : Z12 → Z12 by ϕ(x) := 3 ⊗12 x, for all x ∈ Z12.
(i) Prove that ϕ is a group homomorphism, i.e., show that
(∀ a, b ∈ Z12) ϕ(a⊕12 b) = ϕ(a) ⊕12 ϕ(b).
Your proof must begin “Let a, b ∈ Z12. Then ϕ(a⊕12 b) = . . .
.”
(ii) Complete the following table for the values of the function
ϕ : Z12 → Z12.
x 0 1 2 3 4 5 6 7 8 9 10 11
ϕ(x)
(iii) Use the table to write down the blocks of the partition of
Z12 induced by the homo-
morphism ϕ, i.e., write down
25. ϕ←[0] := {x ∈ Z12 | ϕ(x) = 0}, ϕ←[3] := {x ∈ Z12 | ϕ(x) = 3},
ϕ←[6] := {x ∈ Z12 | ϕ(x) = 6}, ϕ←[9] := {x ∈ Z12 | ϕ(x) = 9}.
(c) Compare your answers to (a)(ii) and (b)(iii). What do you
notice?
1
[The relationship between homomorphisms and cosets is a very
important one and is inves-
tigated further in MAT3DSA.]
5. Let X and Y be set and let ϕ : X → Y be a function. Define a
binary relation ∼ on X by
(∀ a, b ∈ X) a ∼ b ⇐⇒ ϕ(a) = ϕ(b).
Show that ∼ is an equivalence relation on X, i.e., show that
(a) ∼ is reflexive, i.e., (∀ a ∈ X) a ∼ a,
(b) ∼ is symmetric, i.e., (∀ a, b ∈ X) a ∼ b =⇒ b ∼ a,
(c) ∼ is transitive, i.e., (∀ a, b, c ∈ X) a ∼ b & b ∼ c =⇒ a ∼ c.
[These proofs are very short and just use the fact that = is an
equivalence
relation.]
6. Let (G; ·) be a group with identity element e and let H be a
subgroup of G. Define a binary
relation ∼ on G by
(∀ a, b ∈ G) a ∼ b ⇐⇒ a−1b ∈ H.
(a) Prove carefully that ∼ is reflexive, i.e., (∀ a ∈ G) a ∼ a.
26. (b) Prove carefully that ∼ is symmetric, i.e., (∀ a, b ∈ G) a ∼ b
=⇒ b ∼ a.
(c) Prove carefully that ∼ is transitive, i.e., (∀ a, b, c ∈ G) a ∼
b & b ∼ c =⇒ a ∼ c.
In each proof you must indicate where you use any of the
properties (S0), (S1) and (S2)
from the Subgroup Theorem 5.4.
7. Let G and H be groups and let ϕ : G → H be an onto
homomorphism, i.e.,
(1) (∀ y ∈ H)(∃ x ∈ G) ϕ(x) = y, and (2) (∀ a, b ∈ G) ϕ(ab) =
ϕ(a)ϕ(b).
Show that if G satisfies
(∀ g ∈ G) g3 = eG,
then H satisfies
(∀ h ∈ H) h3 = eH.
(You may use without proof the fact that if ϕ : G → H is a
homomorphism, then ϕ(eG) = eH .)
If in your proof you write “Let g ∈ G” before you have written
“Let h ∈ H”, then you have
probably made a mistake!
2
ALC-Prac-11B-solutions.pdf
MAT2ALC Model Answers to Practice Class 11B
1. (a) As H = {0, 4, 8}, we have 1 ⊕12 H = {1 ⊕12 0, 1 ⊕12 4,
27. 1 ⊕12 8} = {1, 5, 9}.
(b) Choosing a = 5 gives 5 ⊕12 H = {5, 9, 1} (or choosing a = 9
gives 9 ⊕12 H = {9, 1, 5}).
(c) Yes, a⊕12 H = 1 ⊕12 H.
[By the Coset Equality Lemma 11.17, this must be true as a ∈ 1
⊕12 H.]
2. (a) H = {0, 5, 10} and the smallest possible value of a is a =
4.
(b) The number of distinct left cosets of H in Z15 is |Z15|/|H| =
15/3 = 5.
(c) a⊕15 H = 9 ⊕15 H = 14 ⊕15 H.
3. (a) The number of distinct left cosets of H in Symm(4) is
|Symm(4)|/|H| = 6/2 = 3.
(b) (1) id◦H = H = {id, (1 2)},
(2) (1 3) ◦H = H = {(1 3) ◦ id, (1 3) ◦ (1 2)} = {(1 3), (1 2 3)},
(3) (2 3) ◦H = H = {(2 3) ◦ id, (2 3) ◦ (1 2)} = {(2 3), (1 3 2)}.
So the distinct left cosets of {id, (1 2)} are {id, (1 2)}, {(1 3),
(1 2 3)} and {(2 3), (1 3 2)}.
4. (a) (i) The number of distinct left cosets of H in Z12 is
|Z12|/|H| = 12/3 = 4.
(ii) (1) 0 ⊕12 H = H = {0, 4, 8},
(2) 1 ⊕12 H = {1, 5, 9},
(3) 2 ⊕12 H = {2, 6, 10},
(4) 3 ⊕12 H = {3, 7, 11}.
So the distinct left cosets of {0, 4, 8} are {0, 4, 8}, {1, 5, 9},
{2, 6, 10} and {3, 7, 11}.
(b) Define ϕ : Z12 → Z12 by ϕ(a) := 3 ⊗12 a, for all a ∈ Z12.
(i) Let a, b ∈ Z12. Then, using the distributive law in the ring
(Z12;⊕12,⊗12), we have
28. ϕ(a⊕12 b) = 3 ⊗12 (a⊕12 b) = (3 ⊗12 a) ⊕12 (3 ⊗12 b) = ϕ(a)
⊕12 ϕ(b).
Hence, ϕ is a group homomorphism.
(ii) x 0 1 2 3 4 5 6 7 8 9 10 11
ϕ(x) 0 3 6 9 0 3 6 9 0 3 6 9
(iii) The the blocks of the partition of Z12 induced by the
homomorphism ϕ are:
ϕ←[0] = {0, 4, 8}, ϕ←[3] = {1, 5, 9}, ϕ←[6] = {2, 6, 10},
ϕ←[9] = {3, 7, 11}.
(c) The partition of Z12 induced by ϕ is exactly the same as the
partition of Z12 into left cosets
of H := ϕ←[0].
[This is no coincidence. For every group homomorphism ϕ : G
→ H, the set H := ϕ←[e] is
a subgroup of G and the partition of G induced by ϕ is exactly
the same as the partition
of G into cosets of H.]
5. Let X and Y be set and let ϕ : X → Y be a function. Define a
binary relation ∼ on X by
a ∼ b ⇐⇒ ϕ(a) = ϕ(b).
(a) [T.P ∼ is reflexive, i.e., (∀ a ∈ X) a ∼ a.] Let a ∈ X. Then
ϕ(a) = ϕ(a) and hence a ∼ a.
Thus ∼ is reflexive.
(b) [T.P ∼ is symmetric, i.e., (∀ a, b ∈ X) a ∼ b =⇒ b ∼ a.] Let
a, b ∈ X with a ∼ b, i.e.,
ϕ(a) = ϕ(b). Then ϕ(b) = ϕ(a) and hence b ∼ a. Thus ∼ is
29. symmetric.
1
(c) [T.P. ∼ is transitive, i.e., (∀ a, b, c ∈ X) a ∼ b & b ∼ c =⇒ a
∼ c.] Let a, b, c ∈ X with
a ∼ b & b ∼ c, i.e., ϕ(a) = ϕ(b) and ϕ(b) = ϕ(c). Then ϕ(a) =
ϕ(c) and hence a ∼ c.
Thus ∼ is transitive.
6. Let (G; ·) be a group with identity element e and let H be a
subgroup of G. Define a binary
relation ∼ on G by
(∀ a, b ∈ G) a ∼ b ⇐⇒ a−1b ∈ H.
(a) [T.P ∼ is reflexive, i.e., (∀ a ∈ G) a ∼ a.] Let a ∈ G. Since
H is a subgroup of G, by (S0) it
contains the identity element e. Thus, a−1a = e ∈ H and hence a
∼ a. Thus ∼ is reflexive.
(b) [T.P ∼ is symmetric, i.e., (∀ a, b ∈ G) a ∼ b =⇒ b ∼ a.]
(c) Let a, b ∈ G and assume that a ∼ b, i.e., a−1b ∈ H. Since H
is a subgroup of G, by (S2)
it is closed under forming inverses. Using ‘Socks and Shoes’
and ‘Double Inverse’, we now
have
a−1b ∈ H =⇒ (a−1b)−1 ∈ H =⇒ b−1(a−1)−1 =⇒ b−1a ∈ H.
Thus b ∼ a, by definition. Hence ∼ is symmetric.
(d) [T.P. ∼ is transitive, i.e., (∀ a, b, c ∈ G) a ∼ b & b ∼ c =⇒ a
∼ c.] Let a, b, c ∈ G.
30. Assume a ∼ b and b ∼ c, i.e., a−1b ∈ H and b−1c ∈ H. As H is
a subgroup of G, by (S1) it
is closed under the group operation. So
a−1b ∈ H & b−1c ∈ H =⇒ (a−1b)(b−1c) ∈ H =⇒ a−1ec ∈ H =⇒
a−1c ∈ H.
Thus a ∼ c, whence ∼ is transitive.
[This is part of the proof of Lemma 11.15.]
7. Let G and H be groups and let ϕ : G → H be an onto
homomorphism. Assume that
(∀ g ∈ G) g3 = eG. (∗ )
[T.P. (∀ h ∈ H) h3 = eH ]. Let h ∈ H. As ϕ is onto, there exists
g ∈ G with ϕ(g) = h. Hence we
have
h3 = hhh
= ϕ(g)ϕ(g)ϕ(g) as ϕ(g) = h
= ϕ(ggg) as ϕ is a homomorphism
= ϕ(eG) as g
3 = eG, by (∗ )
= eH, as ϕ(eG) = eH (given fact)
as required.
2
31. ALC-Prac-8B.pdf
MAT2ALC: Practice Class 8B
Groups of Permutations: NGV Notes, Chapter 7
7.6 Definition. Let X be a set.
• A permutation of X is a function f X → X that is one-to-one
and onto.
• The identity map idX : X → X is given by idX (x) := x, for all
x ∈ X.
7.11 Notation. The set of all permutations of {1, 2, · · · , n} is
denoted by Sn.
Note that Sn is closed under ◦. In fact, (Sn;◦) is a group known
as the symmetric
group (Theorem 7.13), which explains the letter “S”, and has
order n! .
1. Consider the elements f and g of S4 given in table-form by
f =
(
1 2 3 4
2 4 3 1
)
and g =
(
1 2 3 4
4 3 1 2
)
32. .
(a) Write down f(1), g(4), (f ◦g)(2) := f(g(2)), (g ◦f)(2) :=
g(f(2)).
(b) Write each of the following permutations in table-form
(
1 2 3 4
a b c d
)
where a, b, c, d belong
to {1, 2, 3, 4}: f ◦g, g ◦f, f ◦f, f ◦ (f ◦f).
(c) Write the identity permutation id ∈ S4 in table-form: id =
(
1 2 3 4
w x y z
)
.
(d) Write f−1 and id−1 in table form: f−1 =
(
1 2 3 4
a b c d
)
and id−1 =
(
1 2 3 4
33. u v s t
)
.
Cycle Notation. (NGV, pages 68–73)
1
↗ ↘ y
2 4 3
↖ ↙
5
Let h be the permutation (in S5) drawn above. Then, in cycle
notation, we
can write h = (1 4 5 2). By this we mean: h(1) = 4, h(4) = 5,
h(5) = 2,
h(2) = 1, and, since 3 is not listed, h(3) = 3. This permutation
can also be
denoted by (4 5 2 1) or by (5 2 1 4) or by (2 1 4 5). By
convention, we
use the one that has the lowest number first: i.e., (1 4 5 2).
2. The following cycles represents elements of S5: write each in
table-form.
(a) (1 4 5 2), (b) (1 2 3), (c) (2 4).
7.22 The Product of Disjoint Cycles Theorem. Every
permutation f ∈ Sn
is either a cycle or can be written as a product of disjoint
cycles.
For example, in S6, we have
34. (
1 2 3 4 5 6
3 5 6 4 2 1
)
= (1 3 6) ◦ (2 5).
The cycles (1 3 6) and (2 5) are called disjoint since {1, 3,
6}∩{2, 5} = ∅ . It is
usual to omit the “◦” when composing cycles—thus we write(
1 2 3 4 5 6
3 5 6 4 2 1
)
= (1 3 6)(2 5)
and refer to (1 3 6)(2 5) as a product of disjoint cycles.
1
3. (a) Write each of the following elements of S7 as a cycle or a
product of disjoint cycles:
(i)
(
1 2 3 4 5 6 7
4 5 3 6 7 1 2
)
, (ii)
(
35. 1 2 3 4 5 6 7
1 7 6 4 3 5 2
)
.
Let f = (1 3 6 7 2 8) and g = (1 6 2 8 5 4 3). We wish to express
f ◦ g as a
product of disjoint cycles. The answer is given below.
Remember when calculating
f ◦g, you START ON THE RIGHT, i.e., first apply g then apply
f. For example,
(f ◦g)(1) = f(g(1)) = f(6) = 7, so the answer begins (1 7 . . . .
f ◦g = (1 3 6 7 2 8)(1 6 2 8 5 4 3) = (1 7 2)(3)(4 6 8 5)
= (1 7 2)(4 6 8 5)
If you don’t understand how this was obtained, ask for help.
(b) Express each of the following as a cycle or a product of
disjoint cycles. (Remember that
we regard the identity map, id, as a cycle of length one.)
(i) (1 3 5)(1 3 4 6),
(ii) (1 3)(1 2 3),
(iii) (2 7 3 4 5)(2 5 3 8 7 6),
(iv) (1 2 3)3 := (1 2 3)(1 2 3)(1 2 3).
In (iv) do the composition as a single calculation; don’t first
find (1 2 3)(1 2 3).
(c) Read Lemma 7.28 and Example 7.29 on page 74 of the NGV
Unit Notes. Now rewrite each
of your answers to (a)(i)(ii) and (b)(i)–(iv) as products of
36. transpositions.
(d) Read Definition 7.33 on page 76 of the NGV Unit Notes.
Label each of your answers to (c)
as either even or odd.
4. Write each of the following as a cycle or as a product of
disjoint cycles:
(a) (1 6 4)−1,
(b) (a1 a2 · · · an)−1,
(c) (1 6 4 7)(1 2 5)(3 4 6)−1(2 7 6 4).
In (c), first replace (3 4 6)−1, then do the composition as a
single calculation.
5. Let k ∈ {1, 2, · · · , n}. The stabilizer of k in Sn is the set,
denoted by Stabk, of all permutations
f ∈ Sn which have k as a fixed point, i.e.,
Stabk := {f ∈ Sn | f(k) = k}.
As we shall now see, Stabk is a subgroup of the group Sn.
(a) First, consider the case where n = 4 and k = 1. Thus Stab1 ⊆
S4. Write the six elements
of Stab1 in cycle form. (Just leave the identity as id.)
(b) Now consider the general case where n ∈ N and k ∈ {1, 2, ·
· · , n}. We shall prove that
Stabk is a subgroup of Sn by proving (S0), (S1) and (S2): see
The Subgroup Theorem 5.4.
(S0) Explain why id ∈ Stabk. [It’s very easy.]
(S1) Give a careful proof that Stabk is closed under ◦, i.e.,
37. prove that
f ∈ Stabk & g ∈ Stabk =⇒ f ◦g ∈ Stabk.
(S2) Prove that Stabk is closed under forming inverses, i.e.,
prove that
f ∈ Stabk =⇒ f−1 ∈ Stabk.
(c) What is the order of the group Stabk, i.e., |Stabk | = . . . . . .?
2
ALC-Prac-8B-solutions.pdf
MAT2ALC: Model Answers to Practice Class 8B
1. (a) f(1) = 2, g(4) = 2, (f ◦g)(2) = f(g(2)) = f(3) = 3, (g◦f)(2) =
g(f(2)) = g(4) = 2.
(b) f ◦g =
(
1 2 3 4
1 3 2 4
)
; g ◦f =
(
1 2 3 4
3 2 1 4
)
40. (b)(i) (1 5)(3 4 6) = (1 5)(3 6)(3 4), odd; (b)(ii) (1 2), odd;
(b)(iii) (3 8)(4 5)(6 7), odd; (b)(iv) id = (1 2)(1 2), even.
4. (a) (1 4 6); (b) (an an−1 · · · a2 a1) = (a1 an an−1 · · · a2);
(c) (1 2)(3 4 5 6).
5. (a) Stab1 = {id, (2 3 4), (2 4 3), (2 3), (2 4), (3 4)}.
(b) Let n ∈ N and k ∈ {1, 2, · · · , n}.
(S0) id ∈ Sn and id(k) = k; thus id ∈ Stabk.
(S1) Let f ∈ Stabk and g ∈ Stabk, i.e., f ∈ Sn & f(k) = k and g
∈ Sn & g(k) = k.
• [To prove: f ◦g ∈ Stabk, i.e., f ◦g ∈ Sn and (f ◦g)(k) = k.]
We have f ◦g ∈ Sn (as Sn is closed under ◦) and
(f ◦g)(k) = f(g(k)) (definition of ◦)
= f(k) (as g(k) = k)
= k (as f(k) = k).
Thus f ◦g ∈ Stabk, as required.
(S2) Let f ∈ Stabk, i.e., f ∈ Sn and f(k) = k.
[To prove: f−1 ∈ Stabk, i.e., f−1 ∈ Sn.]
We have f−1 ∈ Sn (as Sn is is a group) and
f−1(k) = f−1(f(k)) (since k = f(k) )
= (f−1 ◦f)(k) = id(k) (since f−1 ◦f = id )
= k
Hence f−1 ∈ Stabk.
Since (S0), (S1) and (S2) hold, Stabk is a subgroup of Sn.
(c) The elements of Stabk must fix k but may permute the other
41. n − 1 elements of {1, . . . , n}
in any way at all. Thus |Stabk | = (n − 1)! . [In fact, for all k, `
∈ {1, . . . , n}, the groups
Stabk and Stab` are isomorphic to each other and to the
symmetric group Sn−1.]
ALC-Prac-9A.pdf
MAT2ALC Practice Class 9A Countability
One-to-one and onto functions
A function f : A → B is:
• One-to-one if (∀ x,y ∈ A) x 6= y =⇒ f(x) 6= f(y).
• Onto if (∀ y ∈ B)(∃ x ∈ A) f(x) = y.
1. The function table below gives 4 functions, with domain and
codomain N5.
(a) Which of these functions are one-to-one?
(b) Which of these functions are onto?
(c) Your answers to (a) and (b) should be the same. Is this a
coincidence?
x 1 2 3 4 5
f1(x) 1 2 3 4 5
f2(x) 5 2 5 1 1
f3(x) 1 2 3 4 4
f4(x) 5 4 3 2 1
42. Proving functions are one-to-one
To check that a function f : A → B defined by a formula is
one-to-one, it is usually easier to use the contrapositive:
(∀ x,y ∈ A) f(x) = f(y) =⇒ x = y.
For example, to show that f : R → R with f(x) = 2x − 5 is
one-to-one:
Let x,y ∈ R. Then
f(x) = f(y) =⇒ 2x− 5 = 2y − 5 =⇒ 2x = 2y =⇒ x = y.
2. Let f : N → N be defined by f(n) = 5n + 8.
(a) Check that f is one-to-one.
(b) Is f onto? Explain your answer.
3. Define f : {0, 1}+ → N by f(w) = |w| (where |w| is the length
of w).
(a) Write down f(0),f(00),f(000) and f(01).
(b) Explain why f is not one-to-one.
(c) Explain why f is onto.
4. Define a function f : N →P(N) by f(n) = {n}.
(a) Write down f(1),f(2) and f(100). Are they different?
(b) Check that f is one-to-one.
(c) Explain why f is not onto.
43. Set cardinality
For sets A and B we say:
• |A| = |B| or A and B have the same cardinality if there is a
one-to-one and onto function f : A → B.
• |A| ≤ |B| if there is a one-to-one function f : A → B.
• |A| < |B| if there is a one-to-one function f : A → B but
no one-to-one and onto function f : A → B.
5. (a) Express the answer to Question 2(a) in terms of set
cardinality.
(b) Can we conclude that |N| < |N| from the answer to Question
2(b)?
(c) Express the answer to Question 4 in terms of set cardinality.
(d) Does the answer to Question 3 tell us anything about set
cardinality?
Countable sets
A set A is called countable if |A| ≤ |N| and countably infinite if
|A| = |N|. The elements of a countably infinite set can be written
as an infinite list
x1,x2,x3,x4, . . . .
A set that is not countable is called uncountable.
1
44. 6. Explain why {0, 1}+ is countably infinite by showing how to
write
its elements as an infinite list w1,w2,w3,w4, . . .
7. Here we consider the size of the set M of all of deterministic
finite
state recognition machines with input alphabet Σ = {0, 1}. To
keep things simple, we assume that the set of states of an n state
machine is fixed: Qn = {q0,q1, . . . ,qn−1} and that the initial
state
is q0.
(a) How many ways are there of choosing the set F of accepting
states from the elements of Qn? [Hint: How big is P(Qn)?]
(b) Consider the general form of a transition table for a machine
with n states as shown at below.
(i) How many choices are there for the top left entry δ(0,q0)
(marked ?)?
(ii) How many choices are there for each other entry?
(iii) How many ways are there to fill in the table?
x 0 1
δ(x,q0) ? −
δ(x,q1) − −
...
...
...
δ(0,qn−1) − −
45. (c) Use (a) and (b) to calculate the size of the set Mn of n state
machines.
(d) Which Theorem from the text now tells us that the set M
=⋃∞
n=1 Mn of all deterministic machines is countable?
Inverses and cardinality
Theorem 8.1 says that a function f is one-to-one and onto pre-
cisely if f−1 is a function. We can check that g is the inverse
of f, by checking the following two conditions.
(INV1) g(f(x)) = x for every x in the domain of f.
(INV2) f(g(x)) = x for every x in the domain of g.
8. In Example 8.1.4 it is claimed that the inverse of the function
f :
N → Z defined below is the function g : Z → N also defined
below.
f(n) =
{
1−n
2
if n is odd
n
2
if n is even
g(n) =
46. {
1 − 2n if n ≤ 0
2n if n > 0.
(a) If n is even, is f(n) positive? What if n is odd?
(b) Use your answer to (a) to check that condition (INV1) holds.
(You will need to check the even and odd cases separately.)
(c) Use an approach similar to that of (a) and (b) to check that
(INV2) holds.
(d) Express the answers to (b) and (c) in terms of set
cardinality.
Cantor’s Theorem
Cantor’s Theorem 8.8 says that |A| < |P(A)| for any set A. This
theorem can be used to show that there must be languages that
cannot be recognised by any algorithm (we will discuss how in
Week 12).
9. Here we prove Cantor’s Theorem. Let A be any set (finite or
infinite,
it doesn’t matter).
(a) Show that |X| ≤ |P(A)| by defining a one-to-one function
ψ : A → P(A). [Hint: There is an obvious subset of A
to which you can map a given element x ∈ A.]
(b) Suppose that |A| = |P(A)| so there is a one-to-one and onto
function ψ : X →P(X). Define
E = {x ∈ X : x /∈ ψ(x)}.
Since ψ is onto, there must be some z ∈ X such that ψ(z) = E.
47. We must have either z ∈ E or z /∈ E (you should convince
yourself of this). Now show that both of these assumptions
leads to a contradiction (i.e., an impossibility).
[Hint: Don’t forget that ψ(z) = E .]
(c) What do you conclude?
2
ALC-Prac-9A-solutions.pdf
MAT2ALC Answers to Practice Class 9A
1. (a) f1 and f4.
(b) f1 and f4.
(c) No. If f has the same finite domain and codomain, it will be
onto precisely if it is one-to-one.
2. (a) f(m) = f(n) =⇒ 5m + 8 = 5n + 8 =⇒ 5m = 5n =⇒ m = n.
(b) No. For example, there is no n ∈ N for which f(n) = 1.
3. (a) f(0) = 1,f(00) = 2,f(000) = 3 and f(01) = 2.
(b) For example, the words 00 and 11 are different but f(00) = 2
= f(11).
(c) For any n ∈ N the word 0n is in {0,1}+ and f(0n) = n.
4. (a) f(1) = {1},f(2) = {2} and f(100) = {100} are all different.
(b) f(m) = f(n) =⇒ {m} = {n} =⇒ m = n.
(c) For example, there is no n ∈ N such that f(n) = {1,2}.
48. 5. (a) |N| ≤ |N|.
(b) No. Question 2 doesn’t show that no one-to-one and onto
function f : N → N exists. It just shows
that this particular function is not both one-to-one and onto.
(c) |N| ≤ |P(N)|.
(d) No.
6. 0,1,00,01,10,11,000,001,010,011,100,101,110,111,0000,0001,
. . .
These strings are ordered by length; and those strings which
have the same length, are listed lexico-
graphically.
7. (a) Since we do not include the empty set there are |P(Qn)|−1
= 2n −1 possible choices for F .
(b) (i) n (ii) n (iii) n2n.
(c) |Mn| = n2n(2n −1).
(d) Theorem 8.7, which states: The union of any sequence of
finite sets is countable..
8. (a) If n is even, is f(n) > 0. If n is odd f(n) ≤ 0.
(b) For n even g(f(n)) = 2× n
2
= n and for n odd
g(f(n)) = g(1−n
2
) = 1−2(1−n
2
49. ) = 1− (1−n) = n.
(c) Since g(n) is even for n > 0 we have f(g(n)) = 2n
2
= n and since g(n) is odd (and positive) for
n ≤ 0
f(g(n)) = f(1−2n) = 1−(1−2n)
2
= 2n
2
= n.
(d) |N| = |Z|.
9. (a) The function ψ : X → P(X) → X : x 7→ {x} is one-to-one
since ψ(x) = ψ(y) =⇒ {x} =
{y} =⇒ x = y.
(b) If z ∈ E then z /∈ ψ(z) = E, which is a contradiction.
If z /∈ E then z ∈ ψ(z) = E which is also a contradiction.
(c) Since both cases lead to a contradiction, we conclude that
there can be no such one-to-one and
onto map X →P(X) so |X| < |P(X)|.
ALC-Prac-9B.pdf
MAT2ALC Practice Class 9B
50. Counting Symmetries of Geometric Objects
8.10 Definition (Special Case). Let G be a group of
permutations of X, i.e.,
G is a subgroup of the symmetric group SX , and let x ∈ X. The
stabilizer of x,
denoted Stabx, is defined by
Stabx := {σ ∈ G | σ(x) = x}⊆ G.
The orbit of x, denoted Orbx, is defined by
Orbx := {σ(x) | σ ∈ G}⊆ X.
8.14 The Stabilizer-Orbit Theorem (Special Case) If G is a
finite group of
permutations of a set X, then for each x ∈ X,
|G| = |Stabx|× |Orbx|.
Question 1
Take the equilateral triangle that you have and check that the
vertices have been labelled 1, 2, 3
(front and back, consistently). The group of all 3-dimensional
symmetries of the triangle is denoted
by Symm(4). Recall that each such symmetry will be given by a
motion in 3-dimensional space.
(i) Write the stabilizer of the vertex 1 in terms of permutations
of the vertices; i.e., Stab1 = { ? }.
(ii) Find Stab2 and Stab3.
(iii) What is the orbit of the vertex 1; i.e., Orb1 = { ? }?
(iv) Use the Stabilizer-Orbit Theorem to find the order (i.e., the
51. size) of the group Symm(4).
(v) Does every element of S3 (i.e., every permutation of {1, 2,
3}) correspond to a symmetry of your
equilateral triangle?
Question 2
The group of all 3-dimensional symmetries of a regular
tetrahedron is denoted by Symm(Tetra). Notice
that every symmetry of the tetrahedron which you have can be
represented by a permutation of the
vertices which have been labelled 1, 2, 3, 4.
(i) Find the stabilizer, Stab1, of the vertex 1 in terms of
permutations of the vertices.
(ii) Find Stab2, Stab3, and Stab4.
(iii) Find the orbit of some vertex of the tetrahedron and so
work out the order of Symm(Tetra).
(iv) In (i) and (ii) you found 9 symmetries of the tetrahedron;
find the rest (as permutations of the
vertices). Make sure your answers correspond to 3-dimensional
motions of the tetrahedron.
(v) Does every element of S4 correspond to a symmetry of your
tetrahedron? [What is the order
of S4?]
1
A symmetry of a tetrahedron is actually a permutation of all its
elements (although for
52. simplicity we denote it by the induced permutation of the
vertices). Hence it makes
sense to consider Stabx and Orbx for any point on the
tetrahedron.
Question 3
(i) (a) Let x be the mid-point of the edge 12 of your regular
tetrahedron. What is the size of Orbx?
(b) Find Stabx in terms of permutations of the vertices.
(ii) Repeat (i) with x replaced by y, the point which is 1/3 of the
way along the edge 12.
(iii) Are your answers to (i) and (ii) consistent with the
Stablizer-Orbit Theorem?
Question 4
(i) Use the Stabilizer–Orbit Theorem to find the number of 3-
dimentional symmetries of
(a) a non-square rectangle,
(b) a regular pentagon,
(c) a regular hexagon.
(ii) In each of the cases considered in (i), list the permutations
of the vertices which correspond to
elements of the group of 3-dimensional symmetries.
Question 5
Use the Stabilizer–Orbit Theorem to find the number of 3-
dimensional symmetries of
53. (i) a cube,
(ii) an icosahedron,
(iii) a dodecahedron,
(iv) an octahedron.
tetrahedron cube octahedron
dodecahedron icosahedron(20 vertices, 12 faces) (12 vertices,
20 faces)
2
ALC-Prac-9B-solutions.pdf
MAT2ALC Model Answers to Practice Class 9B
Question 1
(i) Stab1 = {id, (2 3)}
(
=
{
1 2
3
,
1 2
55. 3
or (1 2) =
1 2
3
maps 1 to 2,
and (1 3 2) =
1 2
3
or (1 3) =
1 2
3
maps 1 to 3.
(iv) |Symm(4)| = |Stab1|× |Orb1| = |{id, (2 3)}|× |{1, 2, 3}| = 2 ×
3 = 6, by the Stabilizer-Orbit
Theorem.
(v) Yes every element of S3 yields an element of Symm(4) since
|S3| = 3! = 6.
Question 2
(i) Stab1 = {id, (2 3 4), (2 4 3)}
(
=
{
56. id, 1
2
3
4
, 1
2
3
4
})
.
(ii) Stab2 = {id, (1 3 4), (1 4 3)}, Stab3 = {id, (1 2 4), (1 4 2)},
Stab4 = {id, (1 2 3), (1 3 2)}.
(iii) Orb1 = {1, 2, 3, 4} e.g., (1 3 2) =
1
2
34 maps 1 to 3.
Thus, |Symm(Tetra)| = |Stab1|× | Orb1| = 3 × 4 = 12, by the
Stabilizer-Orbit Theorem.
(iv) Stab1 ∪ Stab2 ∪ Stab3 ∪ Stab4 contains 9 symmetries all
of which fix at least one vertex. Hence
57. the remaining 3 symmetries must fix no vertices at all. They are
(1 4)(2 3)
(1 2)(3 4)
(1 3)(2 4)
e.g., (1 4)(2 3) = 1
2
3
4
(v) NO. For example it is not possible to find a symmetry
corresponding to (1 4). In fact we have
|Symm(Tetra)| = 12 and |S4| = 4! = 24, so exactly half of the
elements of S4 correspond to
symmetries.
1
Question 3
(i) (a) |Orbx| = 6. (b) Stabx = {id, (1 2)(3 4)}.
(ii) (a) |Orby| = 12. (b) Staby = {id}.
(iii) Yes; in (i) 6 × 2 = 12, and in (ii) 12 × 1 = 12.
Question 4
58. (i) (a) Orb1 = {1, 2, 3, 4}, Stab1 = {id}, so |Symm(non-square
rectangle)| = 4 × 1 = 4.
(b) Orb1 = {1, 2, 3, 4, 5}, Stab1 = {(2 5)(3 4), id}, so
|Symm(regular pentagon)| = 5 × 2 = 10.
(c) Orb1 = {1, 2, 3, 4, 5, 6}, Stab1 = {id, (2 6)(3 5)}, so
|Symm(regular hexagon)| = 6×2 = 12.
(ii) (a) {id, (1 2)(3 4), (1 3)(2 4), (1 4)(2 3)}
(b) {id, (1 2 3 4 5), (1 3 5 2 4), (1 4 2 5 3), (1 5 4 3 2), (2 5)(3
4), (3 1)(4 5), (2 4)(1 5), (3 5)(2 1), (1 4)(2 3)}
(c) {id, (1 2 3 4 5 6), (1 3 5)(2 4 6), (1 4)(2 5)(3 6), (1 5 3)(2 6
4), (1 6 5 4 3 2), (2 6)(3 5), (1 3)(6 4),
(2 4)(1 5), (1 2)(3 6)(4 5), (2 3)(1 4)(5 6), (1 6)(2 5)(3 4)}
Question 5
(i) |Orbx| = 8, |Stabx| = 3; |Symm(cube)| = 24.
(ii) |Orbx| = 12, |Stabx| = 5; |Symm(Icos)| = 60.
(iii) |Orbx| = 20, |Stabx| = 3; |Symm(Dodec)| = 60.
(iv) |Orbx| = 6, |Stabx| = 4; |Symm(Octa)| = 24.
Comment. The cube and the octahedron are “dual” polyhedra
with the same symmetry group.
Similarly the icosahedron and dodecahedron are dual. The
tetrahedron is “selfdual”.
(To obtain the dual of a polyhedron we join the centroids of all
the faces.)
2
lecture10A-print.pdf
59. MAT2ALC
Lecture 10A
Non CF Languages
Pumping Lemma
One letter alphabet
Turing Machines
Read/write
String functions
Halting Problems
Power of TM
The gold standard
The limits of
computation
Pumping Lemma
Theorem (9.1. Pumping Lemma for CFL)
Every context free language L has a pumping length p ≥ 1
such that any w ∈ L with |w| ≥ p can be written as
w = uvxyz where:
I |vxy| ≤ p,
I At least one of v and y is non-empty,
60. I uv ixy iz ∈ L for every i ≥ 0.
I Provided w ∈ L is long enough, “pumping it up” as per
the Theorem gives infinitely many different words in L.
I The typical way to show languages are not context free,
uses proof by contradiction:
I Assume the negation of what we want to prove and
show this gives a contradiction.
I In this case, assume L is context free and show this
gives a false conclusion using the pumping lemma.
page 1/19
MAT2ALC
Lecture 10A
Non CF Languages
Pumping Lemma
One letter alphabet
Turing Machines
Read/write
String functions
Halting Problems
61. Power of TM
The gold standard
The limits of
computation
An easier special case
I Pumping lemma may be used to show that the
languages
I L1 = {0n1n2n : n ≥ 1}.
I L2 = {ww : w ∈ {0, 1}+}.
I L3 = {02
n
: n ≥ 0}.
are not context free, for example.
I Pumping Lemma proofs are rather difficult.
I There is an easier way for languages (like L3) with a
one-letter alphabet:
Theorem (9.2: one letter alphabets)
A language L ⊆{a}∗ is context free precisely if it is regular.
page 2/19
MAT2ALC
Lecture 10A
62. Non CF Languages
Pumping Lemma
One letter alphabet
Turing Machines
Read/write
String functions
Halting Problems
Power of TM
The gold standard
The limits of
computation
A non-context free language
Example (9.1.2)
L3 = {02
n
: n ≥ 0} = {0, 00, 0000, 00000000, . . .} is not
context free.
I We show the suffix sets S(02
n
) are all distinct:
I Since 02
63. n
02
n
= 02×2
n
= 02
n+1
∈ L3 for n ≥ 0,
02
n
∈ S(02
n
)
I But for m > n,
02
m
02
n
= 02
m+2n = 02
n(2m−n+1)
cannot be in L since 2n(2m−n + 1) has an odd factor
2m−n + 1 and is therefore not a power of 2.
I This shows so 02
64. n
/∈ S(02
m
), so S(02
m
) 6= S(02
n
).
I Hence L3 is not regular by Theorem 5.3 (infinitely many
suffix sets) and therefore not context free by
Theorem 9.3.
page 3/19
MAT2ALC
Lecture 10A
Non CF Languages
Pumping Lemma
One letter alphabet
Turing Machines
Read/write
String functions
Halting Problems
65. Power of TM
The gold standard
The limits of
computation
What’s the problem?
I We need machines more powerful than PDA to
recognize languages like
I L1 = {0n1n2n : n ≥ 1}.
I L2 = {ww : w ∈ {0, 1}+}.
I L3 = {02
n
: n ≥ 0}.
I Power of PDA are limited by the fact that they access
memory (the stack) at the top only.
I We will define more powerful machines by giving them
“sequential access memory”.
I We allow them to move back and forth, reading and
writing as we go.
I Although this is less efficient than stack processing, it is
much more powerful.
page 4/19
66. MAT2ALC
Lecture 10A
Non CF Languages
Pumping Lemma
One letter alphabet
Turing Machines
Read/write
String functions
Halting Problems
Power of TM
The gold standard
The limits of
computation
Memory as tape
I We picture this new kind of memory as a two-way
infinite “tape” that can store a symbol in each cell.
. . . a b a 1 a b 0 . . .
I During processing, all but finitely many cells are
“blank”. Blank cells are represented by �
. . . � � a b a 1 a b 0 � � . . .
I Currently active cell is the read/write (RW) cell or
67. read/write head represented by an underline.
. . . � � a b a 1 a b 0 � � . . .
I After each step, the value of the RW cell is changed
(but it can be changed to the same symbol, so in fact
can also remain the same).
I Then the RW cell moves either one cell left (L) or one
cell right (R).
page 5/19
MAT2ALC
Lecture 10A
Non CF Languages
Pumping Lemma
One letter alphabet
Turing Machines
Read/write
String functions
Halting Problems
Power of TM
The gold standard
68. The limits of
computation
Turing Machines
I Like FSM and PDA, Turing Machines (TM) have:
I Set Q states and initial state q0.
I Input alphabet Σ.
I Set F of accepting states.
I Partial transition function δ.
I Similar to PDA, they have a tape alphabet Γ with
�∈ Γ.
I Like FSM and PDA, recognition TM reject an input
word if an undefined transition is required.
I Unlike FSM and PDA:
I Input is on tape initially.
I Input alphabet Σ ⊆ Γ {�}.
I They can pass back and forth along input word as many
times as necessary.
I They always have output – the tape contents after
processing ceases.
page 6/19
MAT2ALC
Lecture 10A
Non CF Languages
69. Pumping Lemma
One letter alphabet
Turing Machines
Read/write
String functions
Halting Problems
Power of TM
The gold standard
The limits of
computation
Representing Turing machines
I Symbols in Γ (Σ ∪ {�}) are typically temporary
markers used during computations.
I Partial transition function δ takes:
(current read/write symbol, current state)
and gives:
(symbol to put in RW cell, next state, direction to move ).
I Since RW cell must move either left (L) or right (R):
δ : Γ ×Q → Γ ×Q ×{L,R}
70. I We can represent Turing machines either by directed
graphs or transition tables.
I By convention, we assume RW cell is leftmost
non-blank cell at start of computation.
page 7/19
MAT2ALC
Lecture 10A
Non CF Languages
Pumping Lemma
One letter alphabet
Turing Machines
Read/write
String functions
Halting Problems
Power of TM
The gold standard
The limits of
computation
First TM example
71. Example (9.2.1)
TM accepting L4 = {0n1n : n ∈ N}.
I Q = {q0,q1,q2,q3,q4} I initial state q0.
I Γ = {0, 1,a,�}, Σ = {0, 1} I F = {q4}.
x 0 1 a �
δ(x,q0) (a,q1,R) ∅ (1,q4,L) ∅
δ(x,q1) (0,q1,R) (1,q1,R) (1,q2,L) (�,q2,L)
δ(x,q2) ∅ (a,q3,L) ∅ ∅
δ(x,q3) (0,q3,L) (1,q3,L) (0,q0,R) ∅
q0
q1
q3
q2
q4
0 7→ (a, R)
1 7→ (1, R), 0 7→ (0, R)
1 7→ (1, L),
0 7→ (0, L)
a 7→ (1, L),
� 7→ (�, L)
a 7→ (1, L)
1 7→ (a, L)
72. a 7→ (0, R)
page 8/19
MAT2ALC
Lecture 10A
Non CF Languages
Pumping Lemma
One letter alphabet
Turing Machines
Read/write
String functions
Halting Problems
Power of TM
The gold standard
The limits of
computation
Strategy for a TM
q0
q1
73. q3
q2
q4
0 7→ (a, R)
1 7→ (1, R),
0 7→ (0, R)
1 7→ (1, L),
0 7→ (0, L)
a 7→ (1, L),
� 7→ (�, L)
a 7→ (1, L)
1 7→ (a, L)
a 7→ (0, R)
I We design a Turing Machine with a “strategy” in mind.
In this case:
I If there are 0 and 1 at opposite ends of word, mark
both by a.
I Repeatedly move these a’s toward middle while 0’s and
1’s match.
I Accept the input word if a’s “meet up” in the middle.
page 9/19
74. MAT2ALC
Lecture 10A
Non CF Languages
Pumping Lemma
One letter alphabet
Turing Machines
Read/write
String functions
Halting Problems
Power of TM
The gold standard
The limits of
computation
Configuration notation for TM
I At each step we show (state, abbrev. tape contents) with
RW cell underlined and only show �’s if necessary.
Example (9.2.1 again)
q0
q1
76. Lecture 10A
Non CF Languages
Pumping Lemma
One letter alphabet
Turing Machines
Read/write
String functions
Halting Problems
Power of TM
The gold standard
The limits of
computation
String functions
I Since TM have output, they compute string functions.
Example (9.2.3: halving machine)
TM computes string function f : 0+ → 0+ defined by
f (0n) = 0n/2 for n even (and rejects 0n for n odd).
q0
q1
77. q3
q2
q4
0 7→ (a,R)
0 7→ (0,R)
0 7→ (0,L)
a 7→ (�,L)
� 7→ (�,L)
a 7→ (�,L)
0 7→ (a,L)
a 7→ (0,R)
page 11/19
MAT2ALC
Lecture 10A
Non CF Languages
Pumping Lemma
One letter alphabet
Turing Machines
78. Read/write
String functions
Halting Problems
Power of TM
The gold standard
The limits of
computation
Another configuration notation example
Example (9.2.3 again)
q0
q1
q3
q2
q4
0 7→ (a, R)
0 7→ (0, R)
0 7→ (0, L)
a 7→ (�, L)
� 7→ (�, L)
79. a 7→ (�, L)
0 7→ (a, L)
a 7→ (0, R)
For w = 0000:
(q0, 0000) → (q1,a000) → (q1,a000) → (q1,a000)
→ (q1,a000�) → (q2,a000) → (q3,a00a) → (q3,a00a)
→ (q3,a00a) → (q0, 000a) → (q1, 0a0a) → (q1, 0a0a)
→ (q2, 0a0�) → (q3, 0aa) → (q0, 00a) → (q4, 00�) (accept)
page 12/19
MAT2ALC
Lecture 10A
Non CF Languages
Pumping Lemma
One letter alphabet
Turing Machines
Read/write
String functions
Halting Problems
Power of TM
80. The gold standard
The limits of
computation
TM are not efficient . . .
I Strategy for Example 9.2.3:
I Place marker a at each end of 0n.
I Repeatedly:
I move left a right preserving 0’s.
I move right a left erasing 0’s.
I If a’s meet in middle accept 0n, otherwise reject it
(because n is odd).
I If word is accepted, tape should contain 0n/2.
I The string function f (0n)
could be computed more easily and efficiently by an FSM:
q0 q1 q2
0/0
0/ε
0/ε
I TM are less efficient and harder to program than
simpler PDA or FSM, so why bother?
page 13/19
81. MAT2ALC
Lecture 10A
Non CF Languages
Pumping Lemma
One letter alphabet
Turing Machines
Read/write
String functions
Halting Problems
Power of TM
The gold standard
The limits of
computation
. . . but they are powerful
Previous TM can be modified to give a TM that accepts non
context free language L3 = {02
n
: n ≥ 1}.
q0
q1
q3
82. q2
q4 q5
q6
0 7→ (a, R)
0 7→ (0, R)
0 7→ (0, L) 0 7→ (0, L)
0 7→ (0, R)
a 7→ (�, L)
a 7→ (�, L),� 7→ (�, L)
� 7→ (�, L)
� 7→ (�, R)
a 7→ (0, R)
0 7→ (a, L)
Strategy:
I Repeatedly halve 0n.
I If (non-blank part of) tape is ever 0n for odd n > 1,
reject.
I If (non-blank part of) tape is 0, accept.
page 14/19
83. MAT2ALC
Lecture 10A
Non CF Languages
Pumping Lemma
One letter alphabet
Turing Machines
Read/write
String functions
Halting Problems
Power of TM
The gold standard
The limits of
computation
Computations without end
Example (9.2.6)
I M accepts L = {01}∗ 0 by “simulating” an FSM.
I But N contains a “mistake”.
q0 q1 q2
0 7→ (0, R)
84. � 7→ (�, L)
1 7→ (1, R)
M
q0 q1 q2
0 7→ (0, R)
� 7→ (�, L)
1 7→ (1, L)
N
I N correctly accepts 0 ∈ L and rejects words beginning
with 1 or 00.
I For 010 ∈ L, however:
(q0, 010) → (q1, 010) → (q0, 010) → (q1, 010)
→ (q0, 010) → (q1, 010) → . . .
I N cycles between (q0, 010) and (q1, 010) forever!
I It fails to halt on some inputs (goes into an infinite
loop).
page 15/19
MAT2ALC
Lecture 10A
Non CF Languages
85. Pumping Lemma
One letter alphabet
Turing Machines
Read/write
String functions
Halting Problems
Power of TM
The gold standard
The limits of
computation
The gold standard
I Many variations on the standard TM have been
proposed:
1. Non-deterministic TM.
2. Multiple tape TM.
3. TM with stay put option S as well as L,R.
4. TM with one sided tape extending infinitely in one
direction.
I All have been proven to be equivalent in power to
standard Turing machines.
I Other proposed models of computation have also turned
out to be equivalent (or weaker).
I TM that halt on all inputs are therefore used to define
86. what can be computed by an algorithm.
I Computational complexity analyses efficiency of
computations (in time and space).
I The theory of computational complexity is also based
on TM. A little more on this next week. (For much
more take MAT4CI.)
page 16/19
MAT2ALC
Lecture 10A
Non CF Languages
Pumping Lemma
One letter alphabet
Turing Machines
Read/write
String functions
Halting Problems
Power of TM
The gold standard
The limits of
87. computation
Things TM cannot do
Theorem (9.3)
There are countably many Turing machines with input
alphabet Σ.
I By Theorem 8.9 (uncountably many languages) and
Theorem 9.3, there must therefore be L ∈ P({0, 1}∗ )
that are not accepted by any TM.
I The most famous thing TM cannot do is decide:
Does a given Turing machine M fail to halt when
started with a given input w?
I This is the famous halting problem for TM.
I Although we can often decide this in specific cases, no
TM works in all cases.
I To make sense of this (and to prove Theorem 9.3, we
must encode each TM as a string of symbols.
I Example 9.3.1 in NGV illustrates how to do this.
page 17/19
MAT2ALC
Lecture 10A
Non CF Languages
88. Pumping Lemma
One letter alphabet
Turing Machines
Read/write
String functions
Halting Problems
Power of TM
The gold standard
The limits of
computation
Decision problems
I The halting problem is an example of a decision
problem.
I In this case we seek an algorithm that decides whether
the TM we feed it fails to halt.
I Decision problems for which no TM exists are called
undecidable.
I Many undecidable problems concern context free
grammars. EG:
I Is the language of a given context free grammar G
regular?
I For a given context free grammar G with terminal
89. symbols Σ is the language of G the whole of Σ∗ ?
I Do a given pair of context free grammars G1 and G2
have the same language?
page 18/19
MAT2ALC
Lecture 10A
Non CF Languages
Pumping Lemma
One letter alphabet
Turing Machines
Read/write
String functions
Halting Problems
Power of TM
The gold standard
The limits of
computation
Turing in the neighbourhood
90. “We are not interested in the fact that the brain has the
consistency of cold porridge.”
- Alan Turing
(on a Northern suburbs shop awning).
page 19/19
Non CF LanguagesPumping LemmaOne letter alphabetTuring
MachinesRead/writeString functionsHalting ProblemsPower of
TMThe gold standardThe limits of computation
lecture10B-print.pdf
MAT2ALC
Lecture 10B
Corollaries of
Lagrange’s
Theorem
Classification of
small groups
Lagrange’s Theorem and two other ingredients
Theorem (Lagrange’s Theorem)
Let G be a finite group, and H a subgroup of G . Then |H| is
a divisor of |G|.
Theorem (Order Equals Order)
Let G be a group and let a ∈ G be an element of finite order.
Then, the order of a (in G ) is the same as the order of the
91. cyclic
subgroup 〈a〉 of G generated by a.
Theorem (Equal Powers)
Let m ∈ N. Let G be a group and let a ∈ G be such that
O(a) = m.
1. For all h, k ∈ Z, we have ah = ak if and only if
h ≡ k (mod m).
2. For all n ∈ Z, we have an = e if and only if
n is a multiple of m.
MAT2ALC
Lecture 10B
Corollaries of
Lagrange’s
Theorem
Classification of
small groups
Prime Order Implies Cyclic
Theorem (Prime Order Implies Cyclic)
Let p be a prime and let G be a group with |G| = p. Then
1. G is cyclic.
2. G consists of the identity element e, and p − 1 other
elements, each of order p.
92. 3. G = 〈a〉 = {e, a, a2, . . . , ap−1}, for any a ∈ G {e}.
Proof.
It suffices to prove (3). For an arbitrary a ∈ G with a 6= e,
consider 〈a〉.
I By definition of a cyclic subgroup, we have
〈a〉 = {e, a, a2, . . . , ak} for some k, so |〈a〉| = k + 1.
I By Lagrange’s Theorem, k + 1 divides p. But p is prime
and k 6= 0, so k + 1 6= 1. Therefore, k + 1 = p, that is,
k = p − 1, proving (3).
MAT2ALC
Lecture 10B
Corollaries of
Lagrange’s
Theorem
Classification of
small groups
Two more corollaries
Theorem (Order Divides Order)
Let G be a finite group and let a ∈ G . Then, O(a) divides
|G| (that is, the order of a divides the order of G ).
Proof.
By Order Equals Order Theorem, |〈a〉| = O(a).
93. By Lagrange’s Theorem, O(a) divides |G|.
Theorem (Order Kills All)
Let G be a finite group ot order m, that is, |G| = m. Then,
am = e holds for every a ∈ G .
Proof.
Let a ∈ G . Let k = O(a) = |〈a〉|. Then, ak = e.
By Order Divides Order Theorem, k divides |G| = m.
So, m = kn for some n.
By Equal Powers Theorem, am = akn = (ak )n = en = e.
MAT2ALC
Lecture 10B
Corollaries of
Lagrange’s
Theorem
Classification of
small groups
Recall: isomorphism
Definition
Let G and H be groups, and f : G → H be a map. The map
f is an isomorphism, if
I f is a bijection (that is, one-to-one and onto)
I f is a homomorphism, that is, for any a, b ∈ G we have
94. f (ab) = f (a) · f (b)
If there is an isomorphism f : G → H, we say that G and H
are isomorphic, and write it as G ∼= H.
Lemma
Let G and H be groups, and f : G → H be a map. If f is a
homomorphism, then
I f (eG ) = eH , and
I f (a−1) = f (a)−1 for any a ∈ G
also hold.
MAT2ALC
Lecture 10B
Corollaries of
Lagrange’s
Theorem
Classification of
small groups
Classification “up to isomorphism”
Theorem (Isomorphism is an equivalence relation)
Let G , H, K be groups. The following hold:
I G ∼= G (reflexivity)
I G ∼= H implies H ∼= G (symmetry)
95. I G ∼= H and H ∼= K implies G ∼= K (transitivity)
Thus, ∼= is an equivalence relation on the class of all groups.
I Since isomorphism in an equivalence, it partitions the
class of all groups (recall Lecture 1A) into block
containing groups isomorphic to one another.
I Typically we treat them as one and the same.
I If G ∼= H we often say G and H are the same up to
isomorphism.
I For example, Z2 = ({0, 1};⊕2) and
S2 = ({id, (1 2)},◦) are the same up to isomorphism.
MAT2ALC
Lecture 10B
Corollaries of
Lagrange’s
Theorem
Classification of
small groups
Some helpful results
Theorem (Classification of Cyclic Groups)
Up to isomorphism, there is only one infinite cyclic group
(namely Z) and, for each positive integer m, only one cyclic
group of order m (namely Zm). That is,
96. 1. if G is an infinite cyclic group, then G ∼= Z, and
2. if G is a finite cyclic group with |G| = m, then G ∼= Zm.
I Any two infinite cyclic groups are isomorphic.
I Any two finite cyclic groups of the same order are
isomorphic.
Theorem (Prime Order)
Let p be a prime. Up to isomorphism, there is only one
group of order p. Indeed, if G is a group with |G| = p, then
G ∼= Zp.
MAT2ALC
Lecture 10B
Corollaries of
Lagrange’s
Theorem
Classification of
small groups
More helpful results
Theorem (Groups of Order Four)
Up to isomorphism, there are only two groups of order 4.
Indeed, for any group G with |G| = 4, we have
I if G satisfies (∃ x) x2 6= e, then G ∼= Z4, and
I if G satisfies (∀ x) x2 = e, then G ∼= Klein4, where
97. Klein4 is the symmetry group of the rectangle.
Theorem (Groups of Order Six)
Up to isomorphism, there are only two groups of order 6.
Indeed, for any group G with |G| = 6, we have
I if G is abelian, then G ∼= Z6, and
I if G is not abelian, then G ∼= S3.
Up to isomorphism there are five groups of order 8, only one
of them non-abelian: we have met one of its incarnations in
the last assignment. Let’s not worry about them now.
MAT2ALC
Lecture 10B
Corollaries of
Lagrange’s
Theorem
Classification of
small groups
Detecting non-isomorphism
A recipe for showing that groups G and H are not
isomorphic:
I Find a structural property that holds in G but not in H.
I Roughly: a structural property is a property that does
not depend on “the way a group is given to you”.
I Precisely: it is any property that is preserved by
98. isomorphism. (This is precise but does not say much.
Compare: sleeping pills make you sleepy because they
are dormifacient.)
Example
Consider Klein4 and Z4. Both are of order 4, both are
abelian. But all elements of Klein4 are of order 2, while not
all elements of Z4 are of order 2. Our structural property in
this case is: (∀ x) x2 = e.
I The recipe does say how to find a suitable property. It
is not an algorithm.
MAT2ALC
Lecture 10B
Corollaries of
Lagrange’s
Theorem
Classification of
small groups
Some properties that are structural
The following are some properties of a group G that are
structural:
I G is abelian;
I G is cyclic;
I G has exactly n subgroups;
99. I (∀ x ∈ G ) x2 = e,
I (∀ x ∈ G ) x3 = e, etc;
I (∃ x ∈ G ) x2 6= e,
I (∃ x ∈ G ) x3 6= e, etc;
I G has enough square roots, that is,
(∀ a ∈ G )(∃ x ∈ G ) x2 = a,
I G has enough cube roots, that is,
(∀ a ∈ G )(∃ x ∈ G ) x3 = a, etc;
I G has an element of order m;
I G has exactly k elements of order m.
MAT2ALC
Lecture 10B
Corollaries of
Lagrange’s
Theorem
Classification of
small groups
And yet another useful theorem
Recall from Lecture 5B:
Theorem
Let n, m, m1, . . . , mk ∈ N.
1. The group Zm ×Zn is cyclic if and only if m and n are
relatively prime.
100. 2. The group Zm1 × . . . Zmk is cyclic if and only if
m1, . . . mk are pairwise relatively prime, that is,
gcd(mi, mj ) = 1 for all i 6= j.
Corollaries of Lagrange's TheoremClassification of small
groups
lecture11A-print.pdf
MAT2ALC
Lecture 11A
Computability and
non-computability
Undecidable
Problems
Non-computable
functions
Halting Problem
The Halting Problem for TMs
Given a Turing Machine M and an input I , does M
eventually halt when run on I ?
We are not so much interested in answering this question for
some particular pairs (M, I ), but in a meta-problem
(a problem about a problem):
The Halting Meta-Problem
Is there an algorithmic solution to the Halting Problem?
101. An assumption:
Church Thesis
Any algorithmic procedure can be realised by a Turing
Machine.
There is very good empirical support for Church Thesis, but
it is not a mathematical theorem, and it can never be.
page 1/9
MAT2ALC
Lecture 11A
Computability and
non-computability
Undecidable
Problems
Non-computable
functions
Countably many distinct Turing Machines
I For every pair (k, `) of natural numbers, there are only
finitely many distinct Turing Machines with k states
and using `-symbol tape alphabet.
I We can then enumerate all Turing Machines (TMs) as
follows:
I all TMs with one state and one symbol, T1,1
102. I all TMs with one state and two symbols, T1,2
I all TMs with two states and two symbols, T2,2
I all TMs with two states and one symbol, T1,2
I all TMs with one state and three symbols, T1,3
I and so on ...
number of symbols
no. of states 1 2 3
1 T1,1 T1,2 T1,3
2 T2,1 T2,2 T2,3
...
3 T3,1 T3,2 T3,3
...
. . .
page 2/9
MAT2ALC
Lecture 11A
Computability and
non-computability
Undecidable
Problems
Non-computable
functions
Halting Problem is undecidable: setting up
103. I We saw that Turing Machines can be enumerated. Let
(Mm : m ∈ N) be a list of all TMs.
I Similarly, all inputs can be enumerated, so let
(Ik : k ∈ N) be a list of all inputs.
Suppose there is an algorithm solving the Halting Problem
for TMs. Then, it is an algorithm h(x, y), taking two
arguments, and such that
h(m, k) =
{
YES if Mm halts when run on Ik
NO otherwise
Now, consider the following procedure:
∆(n) =
{
NO if h(n, n) returns YES
YES if h(n, n) returns NO
Under any reasonable definition of “algorithm”, if h is one,
then so is ∆.
page 3/9
MAT2ALC
Lecture 11A
Computability and
104. non-computability
Undecidable
Problems
Non-computable
functions
Halting Problem is undecidable: diagonalisation
Let us now tabulate the outputs of the algorithm h(m, k) in
the following infinite matrix:
List of inputs
List of TMs I1 I2 I3 . . .
M1 h(1, 1) h(1, 2) h(1, 3)
M2 h(2, 1) h(2, 2) h(2, 3)
...
M3 h(3, 1) h(3, 2) h(3, 3)
...
... . . .
Now, here’s the rub. Since ∆(n) is an algorithm, it is
realised by some Turing Machine, and this machine is on the
list of TMs. Say, it is Mi . Let us look at ∆(i).
I Looking at the matrix, we see that ∆(i) = h(i, i)
I But, by the definition of ∆, we have ∆(i) = YES if and
only if h(i, i) = NO.
This is a contradiction!
page 4/9
105. MAT2ALC
Lecture 11A
Computability and
non-computability
Undecidable
Problems
Non-computable
functions
Undecidability
Definition
A problem P is decidable, if there is an algorithm A such
that for every instance I of P:
I if there is a solution to I , then A outputs YES;
I if there is no solution to I , then A outputs NO.
If no such algorithm exists, P is undecidable.
Theorem (Turing, 1937)
The halting problem for Turing Machines is undecidable.
Theorem (Church, 1936)
The problem of determining whether a given first-order
formula ϕ is logically valid is undecidable.
106. page 5/9
MAT2ALC
Lecture 11A
Computability and
non-computability
Undecidable
Problems
Non-computable
functions
Decidable vs. undecidable
Theorem
The following are decidable:
I Given a Finite State Machine M and a string w, does
M accept w?
I Given a Finite State Machine M, does M accept every
string?
I Given a Context Free Grammar G and a string w, does
G generate w?
Constrast the above with
Theorem
107. The following is undecidable:
I Given a Context Free Grammar G , does G generate
every string?
page 6/9
MAT2ALC
Lecture 11A
Computability and
non-computability
Undecidable
Problems
Non-computable
functions
Busy Beaver TMs: preliminaries
Definition
A function f is computable if there is a Turing Machine M
computing f . Otherwise f is non-computable.
I For any m, n ∈ N there are only finitely many Turing
machines with m states and n symbols in the tape
alphabet.
I So, for any m, n ∈ N there are only finitely many Turing
machines with m states and n symbols in the tape
alphabet, such that they halt.
108. I Let these machines be M1, . . . , Mk .
I Each of Mi takes some number of steps before it halts,
let this number be `(i).
I Any machine Mj ∈ {M1, . . . , Mk} such that `(j) is
maximal, is called a Busy Beaver machine for (m, n).
page 7/9
MAT2ALC
Lecture 11A
Computability and
non-computability
Undecidable
Problems
Non-computable
functions
Busy Beaver function
Definition
A Busy Beaver function bb(m, n) is the function which for
each pair of natural numbers (m, n) returns the number of
steps taken by an (m, n) Busy Beaver machine.
Theorem
The function bb(m, n) is not computable.
109. Suppose some TM BB computes bb(m, n). Then the
following algorithm decides (a version of) halting problem.
I Given a machine M, with m states and n symbols in its
tape alphabet, first run BB on (m, n) to determine
bb(m, n).
I Next, run M on blank tape for bb(m, n) + 1 steps.
I If M did not halt, then it never will, because bb(m, n) is
the largest possible number of steps for a halting TM.
page 8/9
MAT2ALC
Lecture 11A
Computability and
non-computability
Undecidable
Problems
Non-computable
functions
Fast growing functions
Non-computable functions grow fast. For example,
I bb(1, 2) = 1
I bb(2, 2) = 6
I bb(3, 2) = 21
110. I bb(4, 2) = 107
I bb(5, 2) ≥ 47, 176, 870
I bb(6, 2) > 7.412 · 1036534
But not all fast growing functions are non-computable.
Ackermann function below is a famous example of such a
computable function.
A(m, n) =
n + 1 if m = 0
A(m − 1, 1) if m > 0 and n = 0
A(m − 1, A(m, n − 1)) if m > 0 and n > 0
A(4, 2) = 22
22
2
− 3.
page 9/9
Computability and non-computabilityUndecidable
ProblemsNon-computable functions
lecture11B-print.pdf
MAT2ALC
Lecture 11B
Partitions revisited
111. Cosets
Finding cosets
Lagrange Theorem
proved
Partition of a set
A partition of a set X is a collection of non-empty subsets of
X (called the blocks) such that every element of X belongs
to precisely one block. More precisely:
Definition
A partition P of a set X is a set of subsets of X such that
1. the blocks of P are non-empty, that is,
∀ B ∈ P : B 6= ∅
2. the blocks of P cover X , that is,
∀ x ∈ X ∃ B ∈ P : x ∈ B
3. the blocks of P are pairwise disjoint, that is,
∀ B, C ∈ P : B 6= C =⇒ B ∩C = ∅
Recall also:
Definition
A relation R ⊆ X ×X is an equivalence relation if R is
reflexive, symmetric and transitive.
MAT2ALC
112. Lecture 11B
Partitions revisited
Cosets
Finding cosets
Lagrange Theorem
proved
Equivalence relations and partitions
Definition
Let ≡ be an equivalence relation on a set X . For any x ∈ X ,
the equivalence class of x, denoted [x]≡ or x/≡, is the set
{y ∈ X : y ≡ x}.
Lemma
Let ≡ be and equivalence relation on a set X . Then, the
equivalence classes of ≡ form a partition of X .
Proof.
Since ≡ is reflexive, x ∈ x/≡, so the blocks are non-empty,
and cover X (that is, every element of X is in some block).
It remains to prove that the blocks are pairwise disjoint. We
prove the contrapositive. Suppose x/≡∩y/≡ 6= ∅ . Then, for
some z ∈ X we have z ∈ x/≡∩y/≡. Take any s ∈ x/≡. We
have s ≡ x ≡ z ≡ y so by transitivity s ∈ y/≡. Thus,
x/≡ ⊆ y/≡, and similarly, y/≡ ⊆ x/≡, so x/≡ = y/≡.
113. MAT2ALC
Lecture 11B
Partitions revisited
Cosets
Finding cosets
Lagrange Theorem
proved
Equivalence relations and partitions
Lemma
Let P be a partition of a set X . Then, the binary relation
defined by x ≡ y if x, y ∈ B, for some block B ∈ P, is an
equivalence relation. Moreover, the equivalence classes of ≡
are precisely the blocks of P.
Proof.
Exercise.
Definition
Let f : X → Z by any function. Define a binary relation ∼
on X by putting x ∼ y if f (x) = f (y).
Lemma
The relation ∼ defined above is an equivalence relation. Its
equivalence classes are inverse images of elements of Y , that
is, the sets f ←[y] = {x ∈ X : f (x) = y}, for each y ∈ Y .
114. MAT2ALC
Lecture 11B
Partitions revisited
Cosets
Finding cosets
Lagrange Theorem
proved
The partition of a group by cosets
Definition
Let (G ;∗ ) be a group, and let H be a subgroup of G . The
subset of G defined by a∗ H = {a∗ h : h ∈ H}, where a is an
element of G , is called a left coset of H containing a.
I Since e ∈ H (because H ≤ G ), we have
a = a ∗ e ∈ a ∗ H, so a ∗ H indeed contains a.
I Since e ∗ H = H the subgroup H is a left coset of itself.
Notation
Typically, we omit the group operation when writing cosets,
so a ∗ H is written as aH. This is not a hard-and-fast rule,
however.
MAT2ALC
115. Lecture 11B
Partitions revisited
Cosets
Finding cosets
Lagrange Theorem
proved
Partition of a group by cosets
Lemma (Partition by cosets)
Let G be a group, and let H be a subgroup of G . Then, the
left cosets of H form a partition of G .
Proof.
We saw that a ∈ aH, for every a ∈ G , so cosets are
non-empty and cover G . It remains to prove that cosets are
pairwise disjoint. We prove the contrapositive. Suppose
aH ∩bH 6= ∅ . Then, for some c ∈ G we have c ∈ aH ∩bH.
Then, c = ah1 = bh2, for some h1, h2 ∈ H, so a = bh2h−11 .
Since H is a subgroup, it follows that a ∈ bH. Take any
d ∈ aH. Then d = ah for some h ∈ H, so d = bh2h−11 h and
thus d ∈ bH. This shows that aH ⊆ bH, and by symmetry,
bH ⊆ aH, so aH = bH.
MAT2ALC
Lecture 11B
Partitions revisited
116. Cosets
Finding cosets
Lagrange Theorem
proved
Cosets: examples
Example
Let H = {id, (12), (34), (12)(34)}≤ S4. We find the coset
(14)H as follows:
I (14)id = (14) I (14)(12) = (124)
I (14)(34) = (143) I (14)(12)(34) = (1243)
Thus, (14)H = {(14), (124), (143), (1243)}. Proceeding
similarly, we can find the coset
(13)H = {(13), (123), (134), (1234)}. But notice:
I (124)id = (124) I (124)(12) = (14)
I (124)(34) = (1243) I (14)(12)(34) = (143)
so (124)H = (14)H. And this is what we should expect!
Lemma (Coset equality lemma)
Let G be a group and H ≤ G . For any a, b ∈ G we have:
aH = bH ⇔b ∈ aH ⇔a−1b ∈ H
117. MAT2ALC
Lecture 11B
Partitions revisited
Cosets
Finding cosets
Lagrange Theorem
proved
Finding all cosets: an algorithm
Given a finite group G and a subgroup H of G , proceed as
follows:
I Put a1 = e and begin the list of cosets with
a1H = eH = H.
I Choose any a2 ∈ G that is not in H, calculate a2H and
add it to the list.
I If H ∪ a2H 6= G , choose any a3 ∈ G (H ∪ a2H),
calculate a3H and add it to the list.
I H ∪ a2H ∪ a3H 6= G , choose any
a4 ∈ G (H ∪ a2H ∪ a3H), calculate a4H and add it to
the list.
I Continue the process until for some ak we have
H ∪ a2H ∪ a3H ∪ ·· ·∪ akH = G .
MAT2ALC
118. Lecture 11B
Partitions revisited
Cosets
Finding cosets
Lagrange Theorem
proved
Finding cosets: examples
Example
Find all cosets of H = {0, 3, 6}≤ Z9. H is there already, so:
I Pick 1 /∈ H; calculate 1 + H = {1, 4, 7}.
I Pick 2 /∈ H ∪ 1 + H; calculate 2 + H = {2, 5, 8}.
I Now, we have H ∪ (1 + H) ∪ (2 + H) = Z9, so we have
finished.
Example
Find a and H, if aH = {7, 11, 13, 14}≤ U15. Recall that
U15 = {1, 2, 4, 7, 8, 11, 13, 14}, with 1 the unit element.
Since a ∈ aH, we can pick, say, a = 7. Then:
I 7 ⊗15 7 = 4 I 7 ⊗15 11 = 2.
I 7 ⊗15 13 = 1 I 7 ⊗15 14 = 8.
I So a = 7 and H = {1, 2, 4, 8}.
But there is a better way....
119. MAT2ALC
Lecture 11B
Partitions revisited
Cosets
Finding cosets
Lagrange Theorem
proved
All cosets are created equal
Lemma (Coset size)
Let G be a group, and let H be a subgroup of G . Then, for
each a ∈ G , we have |aH| = |H|.
Proof.
Define a map fa : H → aH, putting fa(h) = ah. This map is
onto, because every element of aH is of the form ah. It
remains to show that fa is one-to-one. Suppose
fa(h1) = ah1 = ah2 = fa(h2). Then, by left-cancellation,
h1 = h2. So, fa is a bijection from H to aH, and therefore
|aH| = |H|.
But some are more equal than others... think of |H|.
MAT2ALC
Lecture 11B
Partitions revisited
120. Cosets
Finding cosets
Lagrange Theorem
proved
Proof of Lagrange Theorem
Let G be a finite group, and let H be a subgroup of G . We
wish to show that |H| is a divisor of |G|.
I List all the left cosets: a1H, . . . , akH.
I By Partition-by-cosets Lemma, we have that
H ∪ a1H ∪ ·· ·∪ akH = G , and moreover cosets are
pairwise disjoint.
I It follows that |G| = |H| + |a1H| + · · · + |akH|.
I Now, by Coset Size lemma, we have that
|H| = |a1H| = · · · = |akH|, for some n ∈ N.
I Therefore |G| = (k + 1)|H|, so |H| is a divisor of |G| as
required.
Partitions revisitedCosetsFinding cosetsLagrange Theorem
proved
lecture7B-print.pdf
MAT2ALC
Lecture 7B
Linear codes via
binary matrices
121. Determining a
linear code from a
check matrix
Binary matrices
Definition
A binary matrix (technically, a matrix over Z2) is a matrix
whose all entries come from Z2 = {0, 1}.
I We add and multiply binary matrices in the usual way,
except that we carry out the calculations in Z2.
Example
[
1 0 1 0
0 1 1 1
]
·
0 0
1 1
0 1
1 1
[
123. 0
0
0
0
[
0
0
]
MAT2ALC
Lecture 7B
Linear codes via
binary matrices
Determining a
linear code from a
check matrix
Codewords as column vectors
Notation
Let n ∈ N, and let x ∈ V n. We write x′ for the column
vector corresponding to x. That is, if x = x1x2 . . . xn, then
x′ =
125. 1
0
1
1
I If you are not too familiar with vectors, do not worry: it
is yet another piece of notation.
MAT2ALC
Lecture 7B
Linear codes via
binary matrices
Determining a
linear code from a
check matrix
Codes from matrices
Definition
Let r, n ∈ N, r ≤ n, and let H be an r ×n binary matrix.
We define the binary code CH ⊆ V n by
126. CH = {x ∈ V n : H ·x′ = 0′}.
The matrix H is known as a parity check matrix, or simply
check matrix.
Lemma
For any binary matrix H, the code CH is a linear code.
Proof.
It suffices to show that CH is closed under addition. Let
x, y ∈ CH . Observe that we have
(x + y)′ =
[
x1 + y1
.
.
.
xn + yn
]
=
[
x1
.
.
.
xn
]
127. +
[
y1
.
.
.
yn
]
= x′ + y′. Therefore,
H · (x + y)′ = H · (x′ + y′) = H ·x′ + H ·y′ = 0′.
MAT2ALC
Lecture 7B
Linear codes via
binary matrices
Determining a
linear code from a
check matrix
Check matrices in standard form
Theorem
let C ⊆ V n be a linear code. Then there is a binary matrix
H such that C = CH.
Definition
Let H be an m ×n matrix. If H is in the fo
128. 1 0 0 . . . 0 x11 x12 x13 . . . x1(n−m)
0 1 0 . . . 0 x21 x22 x23 . . . x2(n−m)
0 0 1 . . . 0 x31 x32 x33 . . . x3(n−m)
...
...
...
. . .
...
...
...
...
. . .
...
0 0 0 . . . 1 xm1 xm2 xm3 . . . xm(n−m)
we say that H is in standard form.
I Matrices in standard form suffice to determine all linear
codes up to equivalence. We will leave it at that today.
MAT2ALC
Lecture 7B
Linear codes via
129. binary matrices
Determining a
linear code from a
check matrix
How to turn a check matrix into a code
Take this matrix as example
Let H =
[
1 0 1 1
0 1 1 0
]
. Then CH = {x ∈ V 4 : H ·x = 0}.
I So, if x = x1x2x3x4, then
[
1 0 1 1
0 1 1 0
]
·
x1
x2
x3
x4
130. [
0
0
]
.
I This gives the system of two equations
1x1 + 0x2 + 1x3 + 1x4 = 0 = 0x1 + 1x2 + 1x3 + 0x4
that is x1 + x3 + x4 = 0 = x2 + x3.
I Taking x1 and x2 as dependent variables, we get
x1 = x3 + x4 and x2 = x3 (remember, − is + modulo 2).
I Finally, taking all possible combinations of values for
the independent variables x3x4: 00, 01, 10, 11 we
calculate x1x2 from these.
MAT2ALC
Lecture 7B
Linear codes via
binary matrices
Determining a
linear code from a
check matrix
How to turn a check matrix into a code
131. That is, we do the following:
x1 x2 x3 x4
0 0 0 0
1 0 0 1
1 1 1 0
0 1 1 1
I Because x2 = x3.
I Because x1 = x3 + x4.
I This gives 4 codewords: 0000, 1001, 1110, 0111.
I We can now use the check matrix H to check:[
1 0 1 1
0 1 1 0
]
·
1
0
0
1
[
0
0
132. ]
. And similarly for other
codewords.
MAT2ALC
Lecture 7B
Linear codes via
binary matrices
Determining a
linear code from a
check matrix
One more example
I Let H =
0 0 1 0 1
x1
x2
x3
x4
x5
133. 0
gives:
I x1 + x4 = x2 + x5 = x3 + x5 = 0.
I Taking x1, x2, x3 as dependent, we get
I x1 = x4, x2 = x3 = x5
I Now, x4 and x5 can take any values, so we get
x1 x2 x3 x4 x5
0 0 0 0 0
0 1 1 0 1
1 0 0 1 0
1 1 1 1 1
I So the codewords are: 00000, 01101, 10010, 11111.
Linear codes via binary matricesDetermining a linear code from
a check matrix
lecture8A-printout.pdf
MAT2ALC
Lecture 8A
134. Context free
languages (CFLs)
Greibach normal
form
PDA and CFL
Deterministic CFL
Context Free Grammars and Languages
I In a context free grammar (CFG), left hand side of each
rule must be a single non-terminal symbol.
I Any finite string of terminal or non-terminal symbols
can appear on the right, so the rules look like
A → α1α2 . . .αn
where A ∈ N and each αi ∈ N ∪ T .
I A language L is a context free language (CFL) if there
exists a context free grammar that generates L.
I All regular grammars are context free by definition.
I Hence all regular languages are context free.
Context Free Languages
Regular Languages
page 1/16
135. MAT2ALC
Lecture 8A
Context free
languages (CFLs)
Greibach normal
form
PDA and CFL
Deterministic CFL
CFG examples
Example (7.2.1: classic CFL)
L = {0n1n : n ≥ 1} is generated by CFG with T = {0, 1},
N = {σ} and rules
σ → 0σ1
∣ ∣ 01.
Example derivation: σ =⇒ 0σ1 =⇒ 00σ11 =⇒ 000111.
Example (6.4.1: even length palindromes)
L = {wwR : w ∈ {0, 1}∗ } is generated by CFG with
T = {0, 1}, N = {σ} and rules
σ → 0σ0
∣ ∣ 1σ1 ∣ ∣ ε.
Example derivation:
σ ⇒ 0σ0 ⇒ 00σ00 ⇒ 001σ100 ⇒ 001ε100 = 001100.
136. page 2/16
MAT2ALC
Lecture 8A
Context free
languages (CFLs)
Greibach normal
form
PDA and CFL
Deterministic CFL
Context free grammar examples
Example (6.1.2: arithmetic expressions revisited)
A grammar with T = {a,b, +,×, (, )},N = {σ,E} and rules
σ → E + E
∣ ∣ E ×E
E → (E + E )
∣ ∣ (E ×E ) ∣ ∣ a ∣ ∣ b ∣ ∣ c ∣ ∣ d.
Example derivation:
σ =⇒ E + E =⇒ E + (E ×E )
=⇒ a + (E ×E ) =⇒ a + (a ×E )
=⇒ a + (a × (E + E )) =⇒ a + (a × (c + E ))
=⇒ a + (a × (c + b))
137. page 3/16
MAT2ALC
Lecture 8A
Context free
languages (CFLs)
Greibach normal
form
PDA and CFL
Deterministic CFL
Backus-Naur Form (BNF)
I BNF is a standard notation for specifying the syntax of
programming languages.
I It is an alternative notation for context free grammars:
I → is written as ::=.
I Non-terminal symbols are written as < expression > to
indicate their purpose.
I Extended BNF (EBNF) has shortcuts for optional
elements and repetitions.
I This can always be done in a CFG by adding extra rules.
Example (Previous example revisited)
< expr > ::= < subexpr > + < subexpr >∣ ∣ < subexpr > × <
138. subexpr >
< subexpr > ::= (< subexpr > + < subexpr >)∣ ∣ (< subexpr > ×
< subexpr >) ∣ ∣ a ∣ ∣ b ∣ ∣ c ∣ ∣ d
page 4/16
MAT2ALC
Lecture 8A
Context free
languages (CFLs)
Greibach normal
form
PDA and CFL
Deterministic CFL
CFG and PDA
I Context free languages are precisely those accepted by
(not necessarily deterministic) PDA.
I To find a PDA accepting the language of a CFG, we find
an equivalent grammar in Greibach normal form (GNF).
I Algorithms for finding an equivalent Greibach normal
form are complicated. We will not study them.
I Instead, we get an idea of how they work by näıvely
transforming some simple CFG to GNF.
I Given a PDA, it is always possible to give a (rather
complicated) CFG recognising the same language.
139. I We will not attempt this, but these techniques give:
Theorem (7.2)
A language is context free precisely if it is the language
accepted by some (possibly non-deterministic) PDA.
page 5/16
MAT2ALC
Lecture 8A
Context free
languages (CFLs)
Greibach normal
form
PDA and CFL
Deterministic CFL
Greibach normal form
I A grammar where every rule takes one of the following
forms is said to be in Greibach normal form:
(GNF1) A → tB1B2 . . .Bn
(GNF2) A → t
(GNF3) σ → ε
where t ∈ T,A ∈ N and B1,B2, . . . ,Bn ∈ N {σ}.
I Another way to describe (GNF):
140. I σ cannot appear on the RHS of any rule.
I A RHS that is not ε must begin with a terminal.
I A terminal may only ever appear as the first symbol on
the RHS of any rule.
I Rules with terminals appearing on the RHS but not as
first symbol are easily converted to GNF.
I Fixing other problems is not always so easy.
page 6/16
MAT2ALC
Lecture 8A
Context free
languages (CFLs)
Greibach normal
form
PDA and CFL
Deterministic CFL
Removing troublesome terminals
Example (Classic CFL continued)
I To convert our grammar
σ → 0σ1
141. ∣ ∣ 01
for L = {0n1n : n ≥ 1} to GNF, the first task is to get
rid of the 1’s on the RHS.
I We replace them with a new non-terminal B.
I We must also add the rule B → 1:
σ → 0σB
∣ ∣ 0B
B → 1
I This is not yet in GNF due to σ on the right.
page 7/16
MAT2ALC
Lecture 8A
Context free
languages (CFLs)
Greibach normal
form
PDA and CFL
Deterministic CFL
Getting rid of troublesome σ’s
Example (Classic CFL continued)
142. I We can replace the σ on the RHS with a new
non-terminal V .
I We must then duplicate any (GNF1) or (GNF2) rules
with LHS σ replacing σ’s by V ’s:
σ → 0σB
∣ ∣ 0B
B → 1 becomes
σ → 0VB
∣ ∣ 0B
V → 0VB
∣ ∣ 0B
B → 1
I Now we have a GNF grammar. Example derivations:
σ =⇒ 0B =⇒ 01
σ =⇒ 0VB =⇒ 00VBB =⇒ 000BBB
=⇒ 0001BB =⇒ 00011B =⇒ 000111.
page 8/16
MAT2ALC
Lecture 8A
Context free
languages (CFLs)
Greibach normal
143. form
PDA and CFL
Deterministic CFL
Inserting missing terminals
Example (7.2.2)
I For the grammar with T = {0, 1}, N = {σ,U,V} and
σ → UV
∣ ∣ VU
U → 0V
∣ ∣ 0
V → 1U
∣ ∣ 1
the rules for U and V already (GNF1) or (GNF2).
I Substituting rules for U into σ → UV gives (GNF1)
rules σ → 0VV and σ → 0V replacing σ → UV .
I Similarly, we replace σ → VU with two new (GNF1)
rules. The equivalent GNF grammar is:
σ → 0VV
∣ ∣ 0V ∣ ∣ 1UU ∣ ∣ 1U
U → 0V
∣ ∣ 0
V → 1U
144. ∣ ∣ 1
page 9/16
MAT2ALC
Lecture 8A
Context free
languages (CFLs)
Greibach normal
form
PDA and CFL
Deterministic CFL
It does not always work ) -:
Example (7.2.3)
Consider the grammar with T = {0, 1} and N = {σ,U}, and
rules:
I σ → σU
∣ ∣ 1U
I U → 0σ
∣ ∣ 0
I If you apply the method of Example 7.2.2, you will get
rules σ → σσU, σ → σσσU, . . .
I Thus, a more sophisticated approach is sometimes
145. needed.
I Greibach showed that there is an algorithm that always
works.
Theorem (7.1)
Every CFG is equivalent to a grammar in Greibach normal
form.
page 10/16
MAT2ALC
Lecture 8A
Context free
languages (CFLs)
Greibach normal
form
PDA and CFL
Deterministic CFL
GNF → PDA
I We can construct a (typically non-deterministic) PDA
recognising the language of a GNF grammar.
I States Q = {q} I Stack alphabet Γ = N ∪ {z}.
I Accept on empty stack. I Transition table:
Algorithm (7.1)
146. 1. For each (GNF1) rule A → tB1B2 . . .Bn add
(q,B1B2 . . .Bn) to the set δ(t,q,A).
2. For each (GNF2) rule A → t add (q,ε) to δ(t,q,A).
3. If there is a (GNF3) rule σ → ε:
I For each (GNF1) rule σ → tB1B2 . . .Bn add
(q,B1B2 . . .Bnz) to δ(t,q,z).
I For each (GNF2) rule σ → t add (q,z) to δ(t,q,z).
I If there is no (GNF3) rule, we start with σz on the
stack.
I This prevents the PDA from erroneously accepting ε.
page 11/16
MAT2ALC
Lecture 8A
Context free
languages (CFLs)
Greibach normal
form
PDA and CFL
Deterministic CFL
Example with no GNF3 rule
Example
147. I We found the following GNF for L = {0n1n : n ≥ 1}:
σ → 0VB
∣ ∣ 0B
V → 0VB
∣ ∣ 0B
B → 1
I Q = {q}, Γ = {z,σ,V ,B},F = ∅ .
I Start with σz on stack, Transition table above:
x 0 1
δ(x,σ) {B,VB} ∅
δ(x,V ) {B,VB} ∅
δ(x,B) ∅ {ε}
(As usual, we omit states in the transition table in a
one state PDA.)
I Some evolutions:
01: (q,σz)
0→ (q,VBz) 1→ ∅ (Hmmm)
01: (q,σz)
0→ (q,Bz) 1→ (q,z) (Aha! Accept)
0011: (q,σz)
0→ (q,VBz) 0→ (q,BBz) 1→ (q,Bz) 1→ (q,z) (Accept)
001: (q,σz)
0→ (q,VBz) 0→ (q,BBz) 1→ (q,Bz) (Reject)
148. page 12/16
MAT2ALC
Lecture 8A
Context free
languages (CFLs)
Greibach normal
form
PDA and CFL
Deterministic CFL
Example with GNF3 rule
Example
I GNF grammar for L = {0n1n : n ≥ 0}:
σ → 0VB
∣ ∣ 0B ∣ ∣ ε
V → 0VB
∣ ∣ 0B
B → 1
I Q = {q}, Γ = {z,σ,V ,B},F = ∅ .
I Transition table:
Start with z on stack.
x 0 1
149. δ(x,z) {Bz,VBz} {z}
δ(x,σ) {B,VB} ∅
δ(x,V ) {B,VB} ∅
δ(x,B) ∅ {ε}
I Some evolutions:
01: (q,z)
0→ (q,Bz) 1→ (q,z) (Accept)
0011: (q,z)
0→ (q,VBz) 0→ (q,BBz) 1→ (q,Bz) 1→ (q,z) X
001: (q,z)
0→ (q,VBz) 0→ (q,BBz) 1→ (q,Bz) (Reject)
page 13/16
MAT2ALC
Lecture 8A
Context free
languages (CFLs)
Greibach normal
form
PDA and CFL
Deterministic CFL
Determinism
I Non-deterministic PDA can recognise more languages
150. than deterministic PDA.
I A deterministic context free language is one recognised
by some deterministic PDA.
I In Example 6.4.1 we saw that {wwR : w ∈ {0, 1}∗ } is
not deterministic.
I In compiler or interpreter design, determinism is highly
desirable.
I It avoids inefficient backtracking or multi-pass parsing
algorithms.
I Determining whether language of a CFG is deterministic
is difficult. We will not discuss it.
I Instead we discuss a simple type of grammar for which
Algorithm 7.1 always gives a deterministic PDA.
page 14/16
MAT2ALC
Lecture 8A
Context free
languages (CFLs)
Greibach normal
form
PDA and CFL
Deterministic CFL
151. S-Grammars
I A CFG is called an s-grammar or simple grammar if it is
in GNF and:
I For any given A ∈ N and t ∈ T there is at most one
rule with A on the LHS and t on the RHS.
I Such a rule could be either (GNF1) or (GNF2).
Example (Previous example revisited)
I Our GNF grammar for L = {0n1n : n ≥ 1} is not an
s-grammar:
σ → 0VB
∣ ∣ 0B
V → 0VB
∣ ∣ 0B
B → 1
I EG: The rules V → 0VB and V → 0B have same
non-terminal V on LHS and terminal 0 on RHS.
page 15/16
MAT2ALC
Lecture 8A
Context free
languages (CFLs)
152. Greibach normal
form
PDA and CFL
Deterministic CFL
S-Grammars
Example (Previous example revisited)
I An equivalent s-grammar for L = {0n1n : n ≥ 1} has
T = {0, 1},N = {σ,V ,B} and rules
σ → 0V
V → 0VB
∣ ∣ 1
B → 1
I Algorithm 7.1 now gives a PDA with no more than one
choice of transition for each table entry:
x 0 1
δ(x,σ) {V} ∅
δ(x,V ) {VB} {ε}
δ(x,B) ∅ {ε}
I Very easy to give an equivalent deterministic PDA!
page 16/16
Context free languages (CFLs)Greibach normal formPDA and
CFLDeterministic CFL
lecture8B-print.pdf
153. MAT2ALC
Lecture 8B
Permutations
Cycles
Even and odd
permutations
Functions revisited
Definition
Let A and B be sets and let f : A → B be a function.
I f is called one-to-one (or injective) if
(∀ x, y ∈ A) f (x) = f (y) =⇒ x = y (1)
or, equivalently, if
(∀ x, y ∈ A) x 6= y =⇒ f (x) 6= f (y). (1)′
I f is called onto (or surjective) if
(∀ b ∈ B)(∃ a ∈ A) f (a) = b. (2)
I f is called bijective if f is both one-to-one and onto.
Definition
Let X be a set and let f : X → X be a function. If f is a
bijection, then it is called a permutation. We also say that f
permutes the elements of X .
154. MAT2ALC
Lecture 8B
Permutations
Cycles
Even and odd
permutations
Composition and inverse revisited
Definition
Let A, B and C be sets and let f : B → C and g : A → B be
functions. The composition of f and g is a function
f ◦g : A → C defined by
(f ◦g)(a) = f (g(a))
for all a ∈ A.
Mind the notation!
We write f ◦g, so f may seem to come before g. But it is g
that acts first on a in f (g(a)).
Properties of inverse
Let A, B be sets and let f : A → B be a bijection. Then the
inverse function f −1 : B → A exists, and satisfies
(f ◦ f −1)(b) = b (f −1 ◦ f )(a) = a
for all a ∈ A and b ∈ B.
155. MAT2ALC
Lecture 8B
Permutations
Cycles
Even and odd
permutations
Lemma (Composition of permutations is a permutation)
Let X be a set and let f , g : X → X be functions. If f and g
are permutations, then f ◦g is a permutation.
Proof.
First we show that f ◦g is one-to-one. Let x, y ∈ X be such
that f (g(x)) = f (g(y)). Then, g(x) = g(y) because f is
one-to-one. So, x = y because g is one-to-one.
Next we show that f ◦g is onto. Let x ∈ X . Since f is onto,
there is a y ∈ X such that f (y) = x. As g is onto, there is a
z ∈ X such that g(z) = y. Then, f (g(z)) = f (y) = x.
Identity and inverse permutations
I The identity map id : X → X , given by id(x) = x, is a
permutation.
I If f : X → X is a permutation, then f −1 is a
permutation.
156. MAT2ALC
Lecture 8B
Permutations
Cycles
Even and odd
permutations
Table notation
If a function f has finite domain (all transition functions for
finite automata are such), we can write it as a table.
I For example:
x 0 1 2 3 4 5
f (x) 1 2 3 4 5 0
I For permutations we simplify this notation even more
and write f =
(
0 1 2 3 4 5
1 2 3 4 5 0
)
.
Example
All six permutations of the 3-element set {1, 2, 3} are:
158. (
1 2 3
1 3 2
)
.
MAT2ALC
Lecture 8B
Permutations
Cycles
Even and odd
permutations
Table notation: composition and inverse
Example (Composition and inverse)
Let f =
(
1 2 3 4 5
3 1 2 5 4
)
and g =
(
1 2 3 4 5
5 2 3 4 1
159. )
.
f ◦g =
(
1 2 3 4 5
4 1 2 5 3
)
.
I Because g takes 1 to 5, and then f takes 5 to 4, that is:
1
g
→ 5 f→ 4. Similarly, 2
g
→ 2 f→ 1. And so on.
Now, let us try g ◦ f =
(
1 2 3 4 5
3 5 2 1 4
)
.
I Notice that f ◦g 6= g ◦ f . Permutations do not
commute.
Next, f −1 =
(
160. 3 1 2 5 4
1 2 3 4 5
)
=
(
1 2 3 4 5
2 3 1 5 4
)
Turn f upside down and rearrange.
MAT2ALC
Lecture 8B
Permutations
Cycles
Even and odd
permutations
The symmetric group Sn
The set of all permutations on a set X is denoted SX .
The set of all permutations of {1, . . . , n} is denoted Sn.
Theorem (7.13: the symmetric group theorem)
Let X be a set. Then, (SX ;◦) is a group: the identity
element is the identity map idX , and for any f ∈ SX its
inverse is f −1.
Proof sketch. See NGV notes for details.
161. I SX is closed under ◦ (composition of permutations is a
permutation).
I Composition of functions is always associative.
I The identity map is a permutation.
I The inverse map has the required properties.
MAT2ALC
Lecture 8B
Permutations
Cycles
Even and odd
permutations
Cycle notation
Let f =
(
1 2 3 4 5
3 1 2 5 4
)
. We can visualise f as
1
2 3 4
162. 5
And we write it as (1 3 2)(4 5).
We can then recover f by “following the cycles”:
I 1 → 3, so f (1) = 3
I 3 → 2, so f (3) = 2
I 2 → 1, so f (2) = 1
I 4 → 5, so f (4) = 5
I 5 → 4, so f (5) = 4
Let g =
(
1 2 3 4 5
3 1 2 4 5
)
. That is
1
2 3 4
5
We could write it as (1 3 2)(4)(5). But we only write (1 3 2).
MAT2ALC
Lecture 8B
Permutations
163. Cycles
Even and odd
permutations
Composing cycles: intuitions
Let f =
(
1 2 3 4 5
3 1 2 5 4
)
, as before. Consider
g =
(
1 2 3 4 5
3 1 2 4 5
)
, and h =
(
1 2 3 4 5
1 2 3 5 4
)
. So,
1
2 3 4