1 1
Computability, etc.
Recap. Present homework. Grammar and
machine equivalences. Turing history
Homework: Equivalence assignments.
Presentation proposals, preparation. Keep up
on postings.
1
Recap
1 1
1
• Define different types of machines.
– abstract machines
• Machines are fed (my term) strings in a
specified alphabet.
• Machines scan the strings and say yes or
no (accept or reject)
• Each machine accepts strings in a certain
pattern. We call the set of strings in that
pattern a language.
Recap
1 1
1
• Repeat: a language is a SET of strings.
• This set may be finite or infinite.
– the empty set is a language, with no actual
members==elements
• This set may or may not include the empty
string
Homework
1 1
1
• Define a FSA, alphabet {A,blank}, that accepts strings
with even number of As. Define a second FSA that
accepts strings with an odd number of As.
• Define a PDA, alphabet {A, blank,(, ),+} that accepts A,
A+A, (A+A), (A+(A+A)) etc. NOT A+ , not unbalanced (
and ). HOLD OFF ON THIS ONE: SEE HOMEWORK!
• Define TM that subtracts 1. If input is zero, then tape is
cleared.
• Define Turing machine to subtract two numbers a and b,
represented by a+1 1s followed by a blank followed by
b+1 1s
– if (a>=b), put (a-b) + 1 1s on the tape
– if a<b, leave zero 1s in the tape OR return something else if a<b
???
Turing machine
1 1
1
• can perform a function or
• define same type of machine plus
accepting and rejecting states and say a
TM defines a language L if strings in the
language L make the machine stop in an
accepting state and strings NOT in L stop
in a rejecting state.
Decidability
1 1
1
• A TM that always halts is called a decider.
– TM can keep going, that is, loop…
• A language is Turing-decidable if a decider
TM recognizes it.
Univeral Turing Machine
1 1
1
• Consider the input <M,w> where M is
[some encoding for] a Turing Machine and
w is a string.
• Claim: it is possible to define a TM U such
that U simulates M on w! This is
analogous to a general purpose computer.
– may have contributed to idea of stored
program computing
Halting problem
•
•
•
•
1 1
1
Consider a universal Turing machine U.
Now, if a M loops on a w, so would U.
U is not a decider!
Put another way: the set
ATM = {<M,w> | M is a TM and M accepts w}
is undecidable. It can be proven that there does
not exist a TM that always halts, that says yes or
no on all inputs <M,w>.
Recap
1 1
1
• There are different definitions/constructions/concepts
that define the same set of functions or languages.
• So-called recursive functions (more next) correspond to
computable (TM) functions.
• Languages defined by a Regular Expression (look it up)
are languages recognized by a FSA.
• Languages defined by a Context Free Grammar (look it
up) are languages recognized by a PDA.
• Some proofs of equivalence are easy and some more
substantial.
– Will not focus on proofs, BUT these are possible topics for
presentations.
Recursive functions
1 1
1
Define a set of functions by specifying a
starter set and then ways of adding new
functions. Functions can be on vectors.
Stick to integers.
Starter set
• identify function and projection
I(x) = x and Pi(x1,x2,…xn) = xi
• Add 1: A(x) = x+1
• Constant: Ck(x) = k
Ways to add
1 1
1
• Composition: if F and G are recursive (and F produces
the right size vector, then the composition G F (first you
do F and then G to the result) is recursive.
• Primitive recursion: Given functions F and G, define H
H(0,x1, x2, …, xn) = F(x1, x2, … xn) and
H(y+1, x1, x2, … xn)=
G(y,x1, …,xn, H(x1,x2,…,xn))
• Minimal inverse: Given a function F, then the function H
defined by H(x) = y such that F(y) = x and y is the
smallest integer such that that is true.
Equivalence!
1 1
1
• If there exists a TM for a function F, then F
is recursive.
• If a function F is recursive (that is, in this
set), then [you can define] a TM that
performs F.
Grammars
1 1
1
• A grammar G is a
– set of symbols, divided in final symbols and auxiliary
symbols
– (finite) set of production rules of the form
string of symbols => string of symbols
• final symbols have no production rules of the form
f => …
• In this exposition, we view certain strings of letters as
single symbols.
– one auxiliary is called the started symbol s
– The language generated (defined by) G is all the
strings of final symbols generated by a sequence
starting with s
Example
1 1
1
• Think of auxiliaries as parts of speech and
final symbols as (whole) words
• Let
s be sentence
vp be verb phrase
np be noun phrase
n be noun
v be verb
do be direct object
adj be adjective
adv be adverb
Example
• Think of parts of speech
s => np vp
np => adj n | n
vp => v | v adv | v do | v do adv
do => n
n => boy | girl | dog | cheese
v => walks | runs | jumps | eats
adj => short | tall | spotted
adv => fast | slowly
1 1
1
Try
• To construct the parse tree for
tall girl walks
short boy eats cheese slowly
1 1
1
Context free grammar
1 1
• Production rules are of the form
auxiliary symbol => string of symbols
1
So what isn't CFG?
1 1
1
• There also can be rules of the form
aPb => ….
• where P is an auxiliary symbol. Think of it
as: P in the context of a and b produces
something. So this is NOT context-free.
Example CFG
1 1
1
• S => T
T => a
T => a + T
T => (T)
• What language does this produce (list the
terms)?
Regular grammar
1 1
All rules are of the form:
• auxiliary symbol => final symbol or
• auxiliary symbol => single final symbol
followed by an auxiliary symbol
1
1 1
• So a regular grammar is CFG!
1
Regular grammars &
FSA
1 1
1
• Any language accepted by a regular grammar is
accepted by a FSA and
• Any language accepted by a FSA is accepted by
a regular grammar.
Said a different way:
If a language L is accepted by a regular grammar
G, we can define a FSA that accepts it AND if a
language L is accepted by a FSA, we can define
a regular grammar that accepts it.
Informal proof
1 1
1
• Have a Grammar G with production rules of the
accepted form.
• Define a FSA with one state for each auxiliary
symbol, plus one more state. Make the initial
state the one corresponding to the initial symbol.
Add one more state, F and let it be the final
state.
• If P=>aQ, where P and Q are auxiliaries and a is
a symbol in the final alphabet, make an edge
from P to Q, with label a.
• If P=>a, make an edge going from P to F with
label a.
Cont.
1 1
1
• Given a FSA, define a grammar with
auxiliary symbols corresponding to the
states. The initial symbol is the one
corresponding to the initial state.
• Add production rules P=>aQ for all edges
from P to Q.
• Change all production rules P=>aF to
P=>a.
Closure
1 1
1
Regular languages are closed with respect
to various operations, including
concatenation.
• If M is a regular language and N is a
regular language, then we can define MN
is the language made up of all the strings
of the form sm sn where sn where sm is in
M and sn is in N. Then MN also is regular.
Closure
1 1
1
• If M and N are regular languages then so
is the union of M and N.
• This is defined as the set of strings that
are in M or are in N (or both).
• This also is a regular language.
Regular expressions
1 1
1
Yet another equivalent definition!
• A regular expression over an alphabet is a
pattern defined using letters from the
alphabet combined using notation for
union, concatenation, wild card, counts.
• The regular expession defines a set of
strings, that is, a language
CFG and
PDA
Same equivalence here.
1 1
1
Turing history
•
•
•
•
•
1 1
1
Invented what came to be called Turing machines.
Proved various things about them, including Halting
problem
Worked in Bletchley Park during WWII: built a machine
to help decode German codes (codes changed). Given
medal (in secret)
Worked in general area, including spending time at
Princeton with Van Neumann, others. Wrote papers on
computer chess, notion of Turing test
Arrested & convicted for homosexual acts. Made to take
hormone drugs. Appeared to be okay…
Committed suicide
Homework
1 1
1
• Pick 1: Please think about it first instead of or
before trying to look it up. Informal proofs are
okay.
– CFG and PDA equivalence
• If you believe this, then there does exist a PDA for the
homework problem.
– Regular expression and (either) FSA or Regular
grammar equivalence
• Possibilities for presentation topics in Turing
work, history
• Keep up postings
• Shai videos
© Copyright 2026 Paperzz