overview
play

Overview CS20a: NP problems The SAT problem Graph theory S T - PDF document

Overview CS20a: NP problems The SAT problem Graph theory S T T I U T E O F N T A I C E I H N N Computation, Computers, and Programs Recursive functions R O O I 1 I F L L A O G


  1. Overview CS20a: NP problems • The SAT problem • Graph theory S T T I U T E O F N T A I C E I H N N Computation, Computers, and Programs Recursive functions R O O I 1 I F L L A O G http://www.cs.caltech.edu/courses/cs20/a/ November 20, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences Time-bounded TMs • All tapes are 2-way Finite infinite Control • M is DTIME(T(n)) if – M is deterministic – For any input of length n, M takes at most T(n) steps R/W R/W input inp put • M is NTIME(T(n)) – Nondeterministic case Storage tapes U T S T I T E O F N T I A E C I H N N Computation, Computers, and Programs Recursive functions R O O I 2 F I O L L A G http://www.cs.caltech.edu/courses/cs20/a/ November 20, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences NP problems • A problem is in NP if it can be decided yes/no by a nondeterministic TM in O(n c ) steps – n is the length of the input – c is a constant • How long does it take to decide a problem in NP? – It takes O(n c ) time to explore each possible nondeterministic choice – There are an exponential number of choices – So it takes O(2 n ) time worst case • How long does it take to verify an NP execution? – There are O(n c ) steps of size O(n c ) – So it takes O(n 2c ) time T U T E T S I O F I N T E A C I H N N Computation, Computers, and Programs Recursive functions R O O 3 F L I I L O A G http://www.cs.caltech.edu/courses/cs20/a/ November 20, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences

  2. Overview CNF satisfiability • A propositional formula is in conjunctive normal form (CNF) if it is a conjunction of disjunctions of literals. • A literal is a propositional letter, or the negation of a propositional letter. • Every propositional formula can be represented in CNF. (A ∨ ¬ B ∨ C) ∧ (D ∨ ¬ B ∨ ¬ C) ∧ ( ¬ A ∨ B ∨ E ∨ ¬ F) . . . ∧ (E ∨ F ∨ ¬ D ∨ A ∨ ¬ B) S T I T U T E O F N T I A E C I H N N Computation, Computers, and Programs Recursive functions R O O I 4 F I L L A G O http://www.cs.caltech.edu/courses/cs20/a/ November 20, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences Satisfiability algorithm • CNF should make the decision problem easier, since there is only conjunction, disjunction, negation • An algorithm in NP – Guess a truth assignment – Verify the assignment • An algorithm in P – Must be deterministic (no “guessing”) – Just figure out if the formula is true U T S T I T E O F N T A I E C I H N N Computation, Computers, and Programs Recursive functions R O O I 5 F I O L L A G http://www.cs.caltech.edu/courses/cs20/a/ November 20, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences Building an algorithm for 2SAT • 2SAT: each clause has at most two literals A 1 , ¬ A 2 , (A 3 ∨ A 4 ), (A 5 ∨ ¬ A 6 ), . . . • Algorithm – Consider a clause (l ∨ l ′ ) – Rewrite the clauses as implications ( ¬ l ⇒ l ′ ) ∧ ( ¬ l ′ ⇒ l) – Draw a graph – The formula is unsatisfiable iff there are two paths ∗ l 1 ⇒ · · · ⇒ A ∗ l 1 ⇒ · · · ⇒ ¬ A T U T E S T I O F I N T E A C I H N N Computation, Computers, and Programs Recursive functions R O O 6 F L I I L O A G http://www.cs.caltech.edu/courses/cs20/a/ November 20, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences

  3. Overview 2SAT graph A ¬ A S T I T U T E O F N T A I E C I H N N Computation, Computers, and Programs Recursive functions R O O I 7 I F L A L O G http://www.cs.caltech.edu/courses/cs20/a/ November 20, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences Graph theory • A graph is a set of points (vertices) that are interconnected by a set of lines (edges) v2 v3 v6 e1 e4 v5 e9 v1 e3 e7 e5 v8 e8 e6 e10 e2 v7 v4 This is not a vertex U T T S I T E O F N T I A C E I H N N Computation, Computers, and Programs Recursive functions R O O I 8 F I O L L A G http://www.cs.caltech.edu/courses/cs20/a/ November 20, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences Some common graphs T U T E S T I O F I N T E A C I H N N Computation, Computers, and Programs Recursive functions R O O 9 F I L I L O A G http://www.cs.caltech.edu/courses/cs20/a/ November 20, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences

  4. Overview Formal definition of graphs • A graph G is defined as a pair G = (V, E) where – V is a set of vertices – E is a set of edges (v i , v j ), . . . • n = | V | is the size of the graph • | E | is the number of edges S T I T U T E O F N T A I C E I H N N Computation, Computers, and Programs Recursive functions R O O I 10 F I L A L G O http://www.cs.caltech.edu/courses/cs20/a/ November 20, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences Graph definitions • For any edge e = (v i , v j ) , where (v i , v j ) ∈ E , – the edge e is incident with vertices v i and v j – the vertices v i and v j are adjacent . – the degree d(v) of a vertex v is the number of edges that are incident to it. U T S T T I E O F N T A I C E I H N N Computation, Computers, and Programs Recursive functions R O O I 11 I F O L L A G http://www.cs.caltech.edu/courses/cs20/a/ November 20, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences A simple theorem Theorem The number of vertices of odd-degree in a fi- nite graph is even. Proof Note that if we add up all the degrees, we get twice the number of edges. � d(v i ) = 2 · | E | i Since the rhs is even, so is the number of vertices with odd degree. T U T E S T I O F I N T E A C I H N N Computation, Computers, and Programs Recursive functions O R O 12 F I L I L O A G http://www.cs.caltech.edu/courses/cs20/a/ November 20, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences

  5. Overview Path definitions • A subgraph of G is a graph obtained by removing some edges and vertices from G . • A path from v 1 to v n is a sequence P = v 1 , e 1 , . . . , e n − 1 , v n such that e i = (v i , v i + 1 ) • If v n = v 1 , we say the path is a cycle , or circuit • If each vertex appears only once, the path is sim- ple . S T T I U T E O F N T I A E C I H N N Computation, Computers, and Programs Recursive functions R O O I 13 F I L L A G O http://www.cs.caltech.edu/courses/cs20/a/ November 20, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences Path example A simple path A simple cycle A non-simple path U T T S T I E O F N T A I E C I H N N Computation, Computers, and Programs Recursive functions R O O I 14 I F O L A L G http://www.cs.caltech.edu/courses/cs20/a/ November 20, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences Connected components • Two vertices v i , v j are connected if there is a path from v i to v j • The connected components of a graph are a par- tition V 1 , V 2 , . . . , V k ⊆ V in which all vertices are connected. • A connected graph has one component, otherwise it is disconnected • An articulation point is a vertex v whose removal disconnects the graph. T U T E S T I O F I N T E A C I H N N Computation, Computers, and Programs Recursive functions O R O 15 F I L I L O A G http://www.cs.caltech.edu/courses/cs20/a/ November 20, 2002 C Y If this page displays slowly, try turning off the “smooth line art” option in Acrobat, under Edit->Preferences

Recommend


More recommend