370 likes | 396 Views
Complexity and Computability Theory I. Lecture #2 Rina Zviel-Girshin Leah Epstein Winter 2002-2003. Overview. Proofs Finite Automaton. Proofs. Four main types: direct proof (syllogism) proof by construction proof by contradiction proof by induction. Direct proof.
E N D
Complexity and Computability Theory I Lecture #2 Rina Zviel-Girshin Leah Epstein Winter 2002-2003
Overview • Proofs • Finite Automaton Rina Zviel-Girshin @ASC
Proofs • Four main types: • direct proof (syllogism) • proof by construction • proof by contradiction • proof by induction Rina Zviel-Girshin @ASC
Direct proof axioms + rules of deduction (modus ponens) theorems axioms + theorems + rules of deduction theorems All philosophers are wise. Socrates is a philosopher. Socrates is wise. modus ponens: a, ab b Rina Zviel-Girshin @ASC
Proof by Construction The idea: • prove by building a solution (algorithm, automaton) Example: Theorem: There exists a graph with no edges. Proof: Construct such a graph: Q.E.D. Rina Zviel-Girshin @ASC
Proof by Contradiction The idea: • assume the opposite of the theorem • derive a contradiction Rina Zviel-Girshin @ASC
Example Theorem: There does not exist a “greatest natural number” (i.e. N is infinite). Proof: Assume that there is a greatest natural number. Call it x. From our assumption it is obvious that no larger number can exist. Let y = x+1. y is greater than x. y is a natural number. Contradiction to the assumption that x is a greatest natural number. Q.E.D. Rina Zviel-Girshin @ASC
Proof by Induction Three main part: • basis of induction • induction hypothesis • induction step Two types of induction: • Partial induction • Full induction Rina Zviel-Girshin @ASC
Partial induction • Basis of induction – the theorem is true for some natural number k (usually 0, 1) • Induction hypothesis - we assume that the theorem is true for some n • Induction step - proof that assuming the theorem is true for n, it is true for n+1 Rina Zviel-Girshin @ASC
Full induction • Basis of induction – the theorem is true for some natural number k (usually 0, 1) • Induction hypothesis - we assume that the theorem is true for all x n • Induction step - proof that assuming theorem is true for all x n, it is true for n+1 Rina Zviel-Girshin @ASC
Example Theorem: The number of edges in a tree equals to the number of vertices minus 1 (|E|=|V|-1). Proof (by induction on number of vertices): Let n be the number of vertices. • Induction basis: for n=1, a tree of a single vertex has n-1=0 edges. The theorem is, therefore true. • Induction hypothesis:The theorem is true for some n 1 i.e. number of edges in it is n-1. • Induction step:A tree of n+1 vertices is a tree of n vertices, with addition of exactly one vertex and exactly one edge. Therefore the number of edges in the new tree is: The number of edges in a tree of n vertices +1 = (n-1) + 1 = n, where n = number of vertices in the new tree minus 1. Rina Zviel-Girshin @ASC
Finite Automata Informally - our model will include basically: • states • transition between states as a reaction to some input w: Automaton: Rina Zviel-Girshin @ASC
Example Rina Zviel-Girshin @ASC
Formal Definition A finite automaton FA is a 5-tuple (Q, , , q0, F), where: • Q - a finite set of states (all the legal states of the automaton) • - alphabet (a finite set of symbols - alphabet of the input) • - transition function - QQ (given a state and input symbol - what is the next state to be in) • q0 - q0Q is the start state (the initial state, before input) • F - FQ the set of accept states Rina Zviel-Girshin @ASC
Modus operandi • Each state can be accepting or not. • The automaton reads one symbol of the input word (i.e. one letter) at a time. • On each symbol it moves to a new state (defined in transition function) by: • The current state • The symbol read • The automaton stops after the last symbol in the input word is read. • If the state in which it stops is accepting - the automaton accepts (recognized the input word). Rina Zviel-Girshin @ASC
Language of an automaton • Language of an automaton A : L(A) • Informally: the words that A accepts (recognizes), i.e. when reading them it stops in an accepting state. Rina Zviel-Girshin @ASC
Graphical representation starting state not accepting state A: accepting state The language of A: L(A)= { w | |w| is even over ={0,1}} Rina Zviel-Girshin @ASC
Graphical representation • A circle represents a state of the automaton. • The transition function, delta, is represented by directed and labeled edges between states. • Final states have a double circle. • The start state has an incoming arrow. Rina Zviel-Girshin @ASC
Example • Construct an automaton B accepting the following language: L(B)= { w | |w| is odd over ={a,b,c}} B: Rina Zviel-Girshin @ASC
Example • Construct an automaton C accepting the following language: L(C)= { w | w *, ={a,b,c} and a last letter of w is c} C: Rina Zviel-Girshin @ASC
Example • Construct an automaton D accepting the following language: L(D)= { w | w is over * } D: Rina Zviel-Girshin @ASC
Example • Construct an automaton accepting the empty language: L= Rina Zviel-Girshin @ASC
Example • Construct an automaton accepting the following language: L= { w | |w| mod 4=0 is over * } E: Rina Zviel-Girshin @ASC
State diagram • A graphical representation of a finite automaton FA is also called a state diagram. • Given a formal definition of the FA one can draw its state diagram. • Given a state diagram one can write a formal definition of the FA. . Rina Zviel-Girshin @ASC
Example • Consider the finite-state automaton A defined by the state diagram shown below: Q={q0,q1,q2} What are the states Q of A? Rina Zviel-Girshin @ASC
Example • Consider the finite-state automaton A defined by the state diagram shown below: ={a,b} What is the alphabet of A? Rina Zviel-Girshin @ASC
Example • Consider the finite-state automaton A defined by the state diagram shown below: q0 What is the start state of A? Rina Zviel-Girshin @ASC
Example • Consider the finite-state automaton A defined by the state diagram shown below: F ={q0,q1} What are the accept states F of A? Rina Zviel-Girshin @ASC
Example Create the transition table A of A Rina Zviel-Girshin @ASC
Formal description of A The formal description of A is: A={Q={q0,q1,q2} , ={a,b}, A, q0, F={q0,q1}} Rina Zviel-Girshin @ASC
Transition function • Motivation: (delta ) • : QQ • The transition function defines the movement of an automaton from one state to another. • Transition function input is an ordered pair: (current state, current input symbol). • For each pair of "current state" and "current input symbol" the transition function produces as output the next state in the automaton. Rina Zviel-Girshin @ASC
a q0 q1 Example • (q0,a)=q1 means that state q1 is reachable from state q0 by the transition labeled by the input symbol a. • where • q0 is a current state • a is an input symbol • q1 is an output state also called “next state” Rina Zviel-Girshin @ASC
FA description • Draw a FSA according to given and F. : F={q1} Rina Zviel-Girshin @ASC
Example Rina Zviel-Girshin @ASC
Extended transition function • Notation: ’ • ’: Q*Q • The extended transition function ’ defines the movement of an automaton on word w= u. • Formal definition ’(q,u)= (’(q,u), )=m Rina Zviel-Girshin @ASC
q k m Example u where ’(q,u)= (’(q,u), )= (k, )= m Rina Zviel-Girshin @ASC
The language of an automaton • Informally: the words that A accepts (recognizes), i.e. when reading them it stops in an accepting state. • Formally: L(A)={x| x*, ’( q0,x)F} Rina Zviel-Girshin @ASC