300 likes | 425 Views
Finite Model Theory Lecture 9. Logics and Complexity Classes (cont’d). Outline. Proof of Immerman and Vardi’s theorems Normal form for lfp Datalog Other logics capturing complexity classes. Proof: LFP = PTIME. LFP + < µ PTIME [why ?] To show PTIME µ LFP + <
E N D
Finite Model TheoryLecture 9 Logics and Complexity Classes (cont’d)
Outline • Proof of Immerman and Vardi’s theorems • Normal form for lfp • Datalog • Other logics capturing complexity classes
Proof: LFP = PTIME • LFP + < µ PTIME [why ?] • To show PTIME µ LFP + < • Let M = (Q, S, D, d, q0, Qa, Qr) be a PTIME Turing machine • Input: Enc(A) = 01n Enc(R1A)…Enc(RmA) • Output: accept or reject • Need: formula f s.t. A²f iff T accepts A
Proof: LFP = PTIME • Time t and space p vary from 0 to nk-1 • Represent them as k-tuples • Can define t < t’ [ how ? ] • Can define succ(t, t’) [ how ?] • Goal: express the following:T0(p, t) = true iff tape has 0 on p at time tT1(p, t) = true iff tape has 1 on p at time tHq(p, t) = true iff head is on p at time t, state q • All these can be expressed by simultaneous fixpoint [ how ? ]
Proof: PFP = PSPACE • PFP + < µ PSPACE [ why ? ] • To show PSPACE µ PFP + <proceed as before, but can’t define T0(p, t) because we can’t express t • Instead define T0(p), T1(p), Hq(p) using a PFP • Each new step recomputes these tables • Make sure to define T0(p+1) = T0(p) etc whenever reaching an accepting state
Remark • Somewhere in the proof we need to use + and £, defined in terms of < • Where ?
Simultaneous Fixpoints U1, U2, …, Uk = finite sets DefinitionLet F : P(U1) £ … £ P(Uk) ! P(U1) £ … £ P(Uk). A fixpoint for F is X = (X1, …, Xk), X1µ U1, …, Xkµ Uks.t. F(X) = X lfp(F), ifp(F), pfp(F) defined as before
Simultaneous Fixpoints Given • = (f1(R1, …, Rk, x1), …, fk(R1, …, Rk, xk)) lfpRisimult[F](t) , ifpRisimult[F](t) , pfpRisimult[F](t) Mean the following:compute the lfp/ifp/pfpextract the i’th component (since index is Ri)
Simultaneous Fixpoints • LFPsimult = LFP • IFPsimult = IFP • PFPsimult = PFP
Normal Form • Every IFP or LFP formula is equivalent to one formula “with only one LFP, at the top”:9 x1… 9 xk. lfpR[f](x)where f is in FO (i.e. without fixpoints) • Proof: in the book (not hard), but better see next
Datalog • Recall: a conjunctive query has the form:q(x) = 9 y1… 9 yk.f(x, y)where f is a conjunction of positive atomic formulas • Example:stands for 9 u.9 v.(R(x,u) Æ R(u,v) Æ R(v,y)) q(x,y) :- R(x,u), R(u,v), R(v,y)
Datalog Definition. EDBExtensional relations = are those in s Definition. IDBIntensional relations = m new relation names R1, …, Rm Definition. A datalog rule is:where R =intensionalf = conjunctive query R(x) :- f
Datalog Definition. A datalog program is a set of rules: Ri1 :- f1Ri2 :- f2 . . . .Rim :- fm
Examples in Datalog • Transitive closure: • Same generation: T(x,y) :- R(x,y)T(x,y) :- R(x,z), T(z,y) S(x,y) :- Root(u), R(u,x), R(u,y)S(x,y) :- S(u,v), R(u,x), R(v,y)
Datalog Semantics • Simultaneous least fixpoints: • Given a program P, define the operators FP as follows: • FP(R1, …, Rm) = (f1, …, fm) • Next, take the lfp(FP)
Adding negation • Semipositive datalog: • Allow negation only on the EDBs • If we allow negation on IDBs, what is the semantics ?
Semantics 1: Stratified Datalog • Split datalog program into “strata”. Each stratum may use negation of IDBs defined by previous strata. Evaluate program in stages • Example: find pairs x,y that are not connected: T(x,y) :- R(x,y)T(x,y) :- R(x,z), T(z,y)Answer(x,y) :- : T(x,y) here we have 2 strata
Semantics 2: Inflationary Datalog • We know what this is… • Find all pairs x, y that are not connected: T(x,y) :- R(x,y)T(x,y) :- R(x,z), T(z,y)oldT(x,y) :- T(x,y)oldTexceptFinalT(x,y) :- T(x,y), R(x’,z’),T(z’,y’), :T(x’,y’)Answ(x,y) :- :T(x,y), oldT(x’,y’), :oldTexceptFinalT(x’,y’)
Datalog:s½ Datalog:i • Every stratified datalog program can be expressed as an inflationary datalog program • The “winning game” query can be expressed in inflationary datalog but not in stratified datalog [ show the query in class ][ inexpressibility: Kolaitis’91, in Information and Control]
Datalog:i = LFP Theorem Datalog:i = LFP Corollary Datalog:,<i = PTIME
Semantics 3: Partial Fixpoint Datalog Partial fixpoint semantics Theorem Datalog:p = PFP Corollary Datalog:,<p = PSPACE
FO+TrCl Definition Transitive closure. Let f(x, y, z) be a formula, where |x| = |y| = k, and t1, t2 are tuples of length k. Then: [trclx, yf(x, y, z)](t1, t2)is a formula with free variables z.
TrCl • The logic FO extended with trcl is denoted TrCl • Note: may combing trcl arbitrarily with Æ, Ç, :, 8, 9.
Examples in TrCl • Is the graph connected: • Is there a path from u to v where all edges are labeled with the same color:here c is a free variable in trcl • Do we need free variables ? 8 u.8 v.[trclx,y(R(x,y))](u,v) 9 c. .[trclx,y(R(x,c,y))](u,v)
Homework Problem • Let TrClr denote the logic where trcl is applied to tuples x, y with |x| = |y| · r • Consider structures that represent strings over, say S = {a,b}. I.e. s = {<, A, B}. E.g. abbab is represented by ({1,2,3,4,5}, <, A(1),A(4),B(2),B(3),B(5)) • Prove that on strings TrCl1¹ TrCl2
Immerman’s Theorem Theorem TrCl + < = NLOGSPACE Corollary NLOGSPACE is closed under complementation.
Proof Sketch 1. TrCl \subseteq NLOGSPACE Lemma. Denote PosTrCl the language where trcl is used only in positive positions (under even number of negations). Then:PosTrCL + < = TrCl + < You proved it already in 531 ! Plus: recall how inflationary datalog expresses not TC.
Proof Sketch • NLOGSPACE \subseteq TrCl + < • Standard simulation of a Turing Machine
Logics and Complexity Classes DTrCl = transitive closure on deterministic graphs (i.e. where 8x.9· 1y.f(x, y)). Theorem DTrCl+< = LOGSPACE ATrCl = alternating transitive closure [ define in class ] Theorem ATrCl + < = PTIME
Major Open Problem What happens without < ? Open problem. Find a “logic” that captures precisely the order invariant PTIME properties Read 10.7 in the book (pp. 204)