Вы находитесь на странице: 1из 4

Administrivia

Lecture 1: Logic &


Computation
CSCI 81
Spring, 2012
Kim Bruce

Prereqs:

CS 52 or 60 & Discrete Math

Check on-line syllabus for homework/reading


Quick skim of Ch. 1-4, 5.1-5.3 for Friday
( Should be review! )

Homework due Thursdays at midnight


Practice problems can be done together
Those to be turned in should be done on own.

No collaboration without credit

Goals
Describe and use formal systems to model real
phenomena

Understand the dierences between and use of


formal syntax and semantics.

Understand and be able to write proofs in


several formal logic systems.

Understand the importance of the notions of


soundness and completeness for formal logics.

Be able to use formal logics to prove the


correctness of computer programs.

Outline

More Goals
Understand the uses of and dierences
between finite automata, pushdown automata,
and Turing machine models of computation.

Understand and use the correspondence


between formal grammars and the machines
that can recognize them.

Understand the Church-Turing thesis and


several models of universal computation.

Understand and be able to show that a variety


of interesting problems involving computation
are undecidable.

Required Texts
Rich: Automata, Computability, & Complexity

Finite State Machines & Context-Free


Languages

Propositional and Predicate Logic


Turing Machines & Undecidability

Advantages: Informal, readable


Disadvantage: Few proofs (except in index). Provide
algorithms, but not show correct. We usually will!

Huth & Ryan: Logic in Computer Science:


Modelling and Reasoning about Systems.
More formal, lots of coverage beyond basics

Alphabets & Strings

Languages
k is set of strings of length k

An alphabet is a finite non-empty set whose


elements are called symbols or characters.

A string (or word) over is a finite sequence of


elements of .
The empty string is denoted .

The length of a string is the # of letters in it.

0 = {}
k+1 = {xa | x k , a }
Set of all strings over is written * = k0 k

A language is a set of strings over .

Examples:

strings over {0,1} with more 1s than 0s.


strings over {0,1} that do not contain three 0s in a row
{0n1n0n | n 0}

String Operations

Language Classes

Contenation of s, t is written s||t or just st.


is identity: s = s = s

String replication:

Languages

Machines Accepting

Regular

Finite State Machine

Context-free

Pushdown Automata

Decidable

Turing Machines*

Semi-Decidable

Turing Machines

w0 =
wi+1 = wi w

Reversal of w, wR, has inductive definition:


R =
if a is letter, (ua)R = a(uR)

Language Classes

Regular Languages

Can be characterized in 3 ways:


Languages accepted by finite state machines
Languages represented by regular expressions
Language generated by regular grammars

Deterministic Finite State


Machine
A FSM (or DFSM) is a quintuple (K, , , s, A)

Responses depend on states


Car radio or remote control for TV

K is a finite set of states

On FM mode, next takes to next station

is a finite input alphabet

On CD mode, next takes to next track

s K is the start state

See State Pattern for OO languages

A K is set of accepting (or final) states

Could also design transducers

: K K is transition function

Take action when entering or leaving state

Simple model of real computer


finite memory

State Machines

Lexers for programming languages


Example

Terminology

Computations
Single step of M uses to process next character:

Configuration (q,w) K*

(q1,cw) M (q2,w) i (q1,c) = q2

snapshot of current state of a computation

Initial configuration is (s,w) where s is start

M* is reflexive, transitive closure


(q1,u) M* (q2,w) means get from first to second in 0 or

state and w is input.

more steps

Defining Language

Examples

M accepts string w i
there is q A s.t. (s,w) M* (q,)

M rejects string w i

L0 = {w | w contains aab as a substring}

there is q A s.t. (s,w) M* (q,)

L1 = {w | w contains at least two bs}

L(M) = { w * | M accepts w }
L is regular if it is L(M) for some finite state
machine M
Example

Closure Properties
Regular languages are closed under:
Complementation * - L
Intersection L1 L2

(change final set)

(product machine)

Union L1 L2 (deMorgan laws or variant of product)

How about concatenation?


L1 || L2
Cant just put transitions from final of L1 to start of L2!

Also want L*

Вам также может понравиться