b) A problem is computable just in case there is
an algorithm (expressed as a computer
program written in some programming
language) that solves the problem.
led us into a discussion of the binary
system, and how to represent (or code)
letters and symbols into decimal numerals,
how to code decimal numerals as binary
numerals, and how to decode binary
numerals into decimal.
b) Turing's insight:
Every algorithm can be expressed using only
5 verbs (for a Turing machine, i.e., a model
of computation that considers an infinite
tape, divided into squares, with only "0" or "1"
(or nothing) written on each square, and a
reader/printer that can only look at one square
at a time, but that can move back and forth to
* move left
* print "1"
* print "0"
c) (i) Boehm & Jacopini's insight:
Only 3 grammar rules are needed to combine
any set of basic instructions into more complex
* selection (or "choice")
* repetition (or "while-loop")
while <test> do
(where <test> is a "Boolean" test,
i.e., a statement that is either true or false).
(ii) There is also a 4th useful grammar rule:
New instructions can be defined using
the basic instructions combined by the
grammar rules, and then this new
instruction can be given a name.
e.g., Karel's "define-new-instruction"
* e.g., Pascal's "function" declarations
d) The Church-Turing Thesis:
A problem is computable just in case there
is a Turing-machine program that can solve it.
It follows from this and
insight that all programming languages are
equally powerful. However, some are better
for expressing and solving some problems than
others (the same is true about natural languages:
you can say the same things in any natural
language, but sometimes it's easier in one
language rather than another).
"lives" in a 2-dimensional world
* that has walls and beepers
* and Karel can perform 5 basic actions:
can be combined by sequence,
selection, and repetition (which comes
in 2 varieties: while and iterate), and
that can be given new names.
* both selection and repetition require
Karel to be able to perform several
perceptual tests about the presence
or absence of walls and beepers.
* basic actions:
assignment: <memloc> := <value>
where the <value> is either
e.g., x := 5, s := 'jello'
or has to be computed:
e.g., x := 2+3,
s := 'jel' + 'lo',
or s := substr('jelly',1,3)+substr('hello',4,2)
* data types:
we looked at only 2: strings, integers
where strings were implemented as
"varying [n] of char"
* operations on strings:
I/P: <str> + <str>
substr(<str>, <starting-integer>, <length-integer>)
O/P: substring of <str> that begins
at <starting-integer> and has
O/P: integer representing <str>'s length
I/P: index(<str>, <substring>)
O/P: integer representing <substring>'s
location in <str>
* operations on integers:
+, -, *, div, mod
* relations on integers (or strings, for that
(for use in Boolean tests):
=, <>, <, <=, >, >=
c) Assembly Language (for the P88 computer):
* P88 simulated computer:
We used a real computer (the one in
class, or those in the Cybraries, or yours
at home) to simulate a "toy" computer,
called the P88. Note that the P88, by
the Church-Turing Thesis and the Boehm/
Jacopini insight, is just as powerful as the
real computer that it is simulated on!!
consists of a CPU (central processing unit)
The CPU contains 4 registers:
- an Instruction Pointer that points to
the next instruction to be fetched
- an Instruction Register that contains
the current instruction being executed
- a Condition Flag for storing the
result of comparisons
- an Accumulator (AX) for doing
Memory contains registers ("memory
locations") for storing both programs and
* The assembly
language is a programming
language for moving information between
the CPU and the Memory, and for doing
computations and I/O:
copy ax, m
copy m, ax these move info between
the CPU and Memory
out ax these do I/P and O/P,
always from the AX
cmp ax, m compares contents of AX
with contents of a memloc
jnb label these cause control of the
program to jump to the
instruction at the "label"
depending on the result
of the comparison, which
is either a "B" or an "NB"
stored in the CF; this is
how selection and repetition
jmp label unconditional jump
the instruction at the "label"
halt ends the fetch cycle.
* All higher-level
programs in languages
like Pascal (or C++, or Java, etc.) are
"compiled", i.e., translated, into
machine-language programs (written
entirely in 0s and 1s).
programs are simply
machine-language programs that are
readable by humans.
b) Top-Down Design and Stepwise Refinement:
method for solving problems by splitting
them into smaller subproblems, each of
which is easier than the big problem,
and then solving each of the smaller & easier
subproblems by means of top-down design
and stepwise refinement, until you reach a
smallest and easiest subproblem that is so
easy to solve, it can be done by a basic
put off till later what you
don't want to handle today"
of The Cat in the Hat Comes Back,
for those of you familiar with it :-)
c) Text Processing:
An application of strings.
Computation (and mathematics, for that matter)
is not just number manipulation!
d) Artificial Intelligence:
Turing Test = a behavioral test of whether
something (e.g., a computer)
(Answer: It can if it can convince you that
reply to the Turing Test:
Just convincing you that it can think
doesn't mean that it can really think)