• Aucun résultat trouvé

Running Time of Turing Machines via Circuits

6 Approximating Turing Machines

6.4 Running Time of Turing Machines via Circuits

p2

!!CanCirc N Tur

is an approximation system with observable values (which, we recall, are the Boolean constants).

6.4 Running Time of Turing Machines via Circuits

Lemma 36 (quantitative approximation system for Turing machines) Let c0

be the function assigning to a closed canonical M-circuit C the pair (p,m) ∈ N2

where p and m are the height and width of the canonical M-circuit underlying C, respectively.

Let c1 be the function assigning to an arrow f of N Tur the pair(l,m) ∈ N2 where l and m are the number of transitions and the length of the configurations appearing in f , respectively.

With these cost functions, the span of Lemma 28 is a quantitative approximation system.

Proof. Immediate from the definitions.

In the following, givenw ∈(Σ\ {}) of lengthn andm≥n, we define the configurationinitk(w):= (w1,q0)w2· · ·wnm−n, wherewi is thei-th letter ofwandq0the initial state ofM. A configuration of lengthm>0 is accepting if it is of the form(s,q)wfor somes∈Σ,w∈Σm−1. We say thatMacceptsw if there ismand a finite number of transitions frominitm(w) to an accepting state.

Theorem 37 Let M be a Turing machine with alphabetΣ and degree of non deter-minism d. Then, the following are equivalent:

• M accepts w∈(Σ\ {})in l steps and using at most m cells of its tape;

• there existsj∈[d]l such that Clm(M)(initm(w);j)→1.

The above result is an instance of Theorem 9, via Lemma 36, although of course it may be proved directly and immediately from the definitions. The goal here is not to do more work than necessary to prove an essentially trivial result, but to show that it also fits in our framework of approximations. This is remarkable because Theorem 37 has a number of important consequences.

We start by observing that, if we make the innocuous assumption that, for any halting state qof any Turing machine M, we have, for alls,s−1,s0,s1 ∈ Σ and j ∈ [d], δM((s,q),s0,s1,j) = s0, δM(s−1,(sq),s1,j) = (s,q) and δM(s−1,s0,(s,q),j) = s0 (i.e., M acting on halting configurations does noth-ing), we obtain the following:

Lemma 38 If Cmp(γ;j)→b with b∈ {0, 1}, then for any k∈Nand anyj0 ∈[d]k, Cmp+k(γ;j0j)→b.

With the help of the above result, the first application of Theorem 37 is the famous Cook-Levin theorem:

Theorem 39 (Cook-Levin) satisNP-complete with respect to logspace reductions.

Proof. Membership is obvious, the non-trivial part is showing hardness.

There is a well-known logspace reduction from circuit sat to sat (see e.g.

[Pap94]), so it is enough to show thatcircuit satisNP-hard with respect to logspace reductions. We remind that circuit sat is the following problem:

given a Boolean circuit, is there a way to set its inputs so that it evaluates to 1?

So letL∈ NP. We need to exhibit a logspace-computable functionrsuch that, for everyw∈ {0, 1},w∈ Liffr(w)∈circuit sat. SinceL∈NP, there

is a non-deterministic Turing machine MdecidingLin polynomial time. Let Σ,Q, d and p be the alphabet, set of states, degree of non-determinism and polynomial bounding the running time of M, respectively.

Now, the key observation is that, sinceδM is a finite function, modulo an (arbitrary) encoding of the elements of H := Σ+ (Σ×Q)as binary strings, δMmay be computed by a finite family(Bi(M))1≤i≤kof Boolean circuits with 3k+logd inputs (supposing that integers are represented in binary), where k is an integer such that 2k ≥ |H|, depending on the encoding. Given the binary encodings of h−1,h0,h1 ∈ H and j ∈ [d], each Bi(M) computes the i-th bit of the binary encoding of δM(h−1,h0,h1,j). The same holds for the functionH→ {0, 1}mapping(s,q)∈Σ×Qto 1 wheneverqis accepting, and mapping anything else to 0: since it is a finite function, it may be implemented by a Boolean circuit withkinputs and one output.

IfTurCircand BoolCircare the categories of (not necessarily closed) Tur-ing circuits and Boolean circuits, respectively, with evaluations as arrows, the above defines a functor

enc :TurCirc−→ BoolCirc

mapping every closed canonical circuit to its implementation. Notice that every free variable of typechoiceofCwill induce logdinputs in enc(C).

Given w ∈ (Σ\) of length n, we know that M terminates in at most p(n)steps, during which it cannot use more thatp(n)cells of the tape. So let

r(w):=enc(Cp(n)p(n)(M)(initp(n)(w);−)),

where the dash indicates that we leave unset thep(n)logdinputs correspond-ing to thep(n)free variables of typechoiceofCp(n)p(n)(M). Now:

w∈LiffMacceptswinp(n)steps usingp(n)cells iff there existsj∈[d]p(n)such thatr(w)(j)→1 iffr(w)∈circuit sat

where byr(w)(j)we denote the closed Boolean circuit obtained by setting the inputs ofr(w)to the encodings of the various elements ofj. The first double implication is given by definition and Lemma 38 (even if, in general,Mmight take strictly less thanp(n)steps, that lemma tells us that we may round up to p(n)by adding some “do nothing” transitions), the second double implication is Theorem 37 and the third is again by definition.

To conclude the proof, we need to check thatr is logspace computable.

This is clear because|r(w)| =O(p(n)2), asCp(n)p(n)(M)(initp(n)(w);−) contains p(n)2 occurrences ofO, one occurrence ofHand O(p(n)) ground constants, and these are all mapped to circuits of constant size.

In the special case of deterministic Turing machines, the above proof gives another famous result:

Theorem 40 (Ladner) circuit valueisP-complete with respect to logspace reduc-tions.

Proof. Recall that circuit value is the following problem: given a closed Boolean circuit (i.e., with no unfixed input), does it evaluate to 1? As above, membership inPis obvious, so we need to proveP-hardness.

Now, by inspecting the proof of Theorem 39, we see that the Boolean cir-cuit r(w) has p(n)logd unset inputs. Hence, if the polytime machine M is deterministic,d =1 andr(w)is a closed Boolean circuit (indeed, the canoni-cal M-circuitsCmp(M)do not depend on their free variable of typechoice). So, if Lhappens to be decided by a polytime deterministic Turing machine,r re-ducesLtocircuit value. But the class of problems decided by deterministic

polytime Turing machines is exactlyP.

Finally, we have yet another avatar of the Cook-Levin theorem:

Theorem 41 Pis the class of languages decided byDLOGTIME-uniform families of Boolean circuits of polynomial size.

Proof. That a DLOGTIME-uniform family of Boolean circuits decides a lan-guage inPis immediate. For the converse, letL∈Pbe decided by a machine M with a polynomial bound pand let, for n ∈ N,Cn be the Boolean circuit enc(Cp(n)p(n)(M))((x1,q0)x2· · ·xnp(n)−n), where by this notation we mean that we fixed the inputs so that the state is the initial one and the tape is filled with blanks, except for the first nsymbols, the corresponding inputs of which are left unset. By Theorem 37, (Cn)n∈N is a family of Boolean circuits deciding L. It is of polynomial size: as already observed in the proof of Theorem 39, the size of Cn isO(p(n)2). The fact that it is DLOGTIME-uniform is a stan-dard result that we do not wish to prove here, as it would require too many

additional technical definitions.

References

[AB17] Beniamino Accattoli and Bruno Barras. Environments and the complexity of abstract machines. In Proceedings of PPDP, pages 4–16, 2017.

[ABM14] Beniamino Accattoli, Pablo Barenbaum, and Damiano Mazza. Dis-tilling abstract machines. In Proceedings of ICFP, pages 363–376, 2014.

[ADLV20] Beniamino Accattoli, Ugo Dal Lago, and Gabriele Vanoni. The machinery of interaction. In Proceedings of PPDP, pages 4:1–4:15, 2020.

[ADLV21] Beniamino Accattoli, Ugo Dal Lago, and Gabriele Vanoni. The (in)efficiency of interaction.Proceedings of the ACM on Programming Languages, 5(POPL), 2021.

[CT20] Jules Chouquet and Christine Tasson. Taylor expansion for call-by-push-value. InProceedings of CSL, pages 16:1–16:16, 2020.

[dC07] Daniel de Carvalho. Sémantiques de la logique linéaire et temps de calcul. Ph.d. thesis, Université de la Méditerranée – Aix-Marseille 2, 2007.

[dC18] Daniel de Carvalho. Execution time of λ-terms via denota-tional semantics and intersection types. Math. Struct. Comput. Sci., 28(7):1169–1203, 2018.

[ER06] Thomas Ehrhard and Laurent Regnier. Böhm trees, krivine’s ma-chine and the taylor expansion of lambda-terms. InProceedings of CiE, pages 186–197, 2006.

[ER08] Thomas Ehrhard and Laurent Regnier. Uniformity and the taylor expansion of ordinary lambda-terms. Theor. Comput. Sci., 403(2-3):347–372, 2008.

[Gar94] Philippa Gardner. Discovering needed reductions using type the-ory. InProceedings of TACS, pages 555–574, 1994.

[Gir89] Jean-Yves Girard. Geometry of interaction I: Interpretation of sys-tem F. InProceedings of Logic Colloquium 1988, pages 221–260, 1989.

[Kfo00] A. J. Kfoury. A linearization of the lambda-calculus and conse-quences. J. Log. Comput., 10(3):411–436, 2000.

[Maz17] Damiano Mazza. Polyadic Approximations in Logic and Computation.

Habilitationthesis, Université Paris 13, 2017.

[MPV18] Damiano Mazza, Luc Pellissier, and Pierre Vial. Polyadic approx-imations, fibrations and intersection types. Proceedings of the ACM on Programming Languages, 2(POPL:6), 2018.

[MZ15] Paul-André Melliès and Noam Zeilberger. Functors are type re-finement systems. InProceedings POPL, pages 3–16, 2015.

[Pap94] Christos H. Papadimitriou. Computational complexity. Addison-Wesley, 1994.

Documents relatifs