Complexity and Computability Theory I Lecture #2 Rina Zviel-Girshin Leah Epstein Winter
Rina Overview Proofs Finite Automaton
Rina Proofs Four main types: –direct proof (syllogism) –proof by construction –proof by contradiction –proof by induction
Rina 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, a b b
Rina 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 Proof by Contradiction The idea: assume the opposite of the theorem derive a contradiction
Rina 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 Proof by Induction Three main part: basis of induction induction hypothesis induction step Two types of induction: Partial induction Full induction
Rina 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 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 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 Finite Automata Informally - our model will include basically: states transition between states as a reaction to some input w: Automaton:
Rina Example
Rina Formal Definition A finite automaton FA is a 5-tuple (Q, , , q 0, 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 - Q Q (given a state and input symbol - what is the next state to be in) q 0 - q 0 Q is the start state (the initial state, before input) F - F Q the set of accept states
Rina 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 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 Graphical representation A: accepting state not accepting state starting state The language of A: L(A)= { w | |w| is even over ={0,1}}
Rina 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 Example Construct an automaton B accepting the following language: L(B)= { w | |w| is odd over ={a,b,c}} B:
Rina 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 Example Construct an automaton D accepting the following language: L(D)= { w | w is over * } D:
Rina Example Construct an automaton accepting the empty language: L=
Rina Example Construct an automaton accepting the following language: L= { w | |w| mod 4=0 is over * } E:
Rina 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 Example Consider the finite-state automaton A defined by the state diagram shown below: What are the states Q of A? Q={q0,q1,q2}
Rina Example Consider the finite-state automaton A defined by the state diagram shown below: What is the alphabet of A? ={a,b}
Rina Example Consider the finite-state automaton A defined by the state diagram shown below: What is the start state of A? q0
Rina Example Consider the finite-state automaton A defined by the state diagram shown below: What are the accept states F of A? F ={q0,q1}
Rina Example Create the transition table A of A AA ab q0q1q0 q1 q2 q1q0
Rina Formal description of A The formal description of A is: A={Q={q0,q1,q2}, ={a,b}, A, q0, F={q0,q1}}
Rina Transition function Motivation: ( delta ) : Q Q 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 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” q0 q1 a
Rina FA description Draw a FSA according to given and F. State/ input symbol 01 q0q1q3 q1 q2 q1q2 q3 F={q1} ::
Rina Example
Rina 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 Example qkm u where ’(q,u )= ( ’(q,u), )= (k, )= m
Rina 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 *, ’( q 0,x) F}