# (How) Could we discover/analyze NP problems in the absence of the Turing model of computation?

From a purely abstract math/computational reasoning point of view, (how) could one even discover or reason about problems like 3-SAT, Subset Sum, Traveling Salesman etc.,? Would we be even able to reason about them in any meaningful way with just the functional point of view? Would it even be possible?

I've been mulling on this question purely from a point of self inquiry as part of learning the lambda calculus model of computation. I understand that it's "non-intuitive" and that's why Godel favored the Turing model. However, I just wish to know what are the known theoretical limitations of this functional style of computation and how much of a hindrance would it be for analyzing the NP class of problems?

• This is not a research-level question for someone who does programming language theory professionally, but I still don't think the qustion deserves all the downvotes. Could the downvoters tell us what bothers them? Perhaps the question can be improved. – Andrej Bauer Nov 28 '16 at 22:02
• @AndrejBauer: I downvoted because (1) I think that the (polynomial) equivalence between Turing machines and the lambda calculus is fairly well-known, and (2) the post has a lot of fluff which masks that as the core question. However, your answer shows that there is more going on than I thought, so I may reverse my vote. – Huck Bennett Nov 28 '16 at 22:07
• I agree that the fluff belongs to Discovery Channel. – Andrej Bauer Nov 28 '16 at 22:09
• @AndrejBauer, HuckBennet: I initially was deciding to post this on the computer science portal but I couldn't find the relevant tags and hence posted it here. I removed the fluff to help be direct with what it is that I want to know. I've left my "reason" for asking the question and hence tagged it as a soft question. I'm genuinely interested in knowing how one could analyze NP problems purely from a functional perspective and if there is indeed any value in doing that - with the hope that I understand something more deeply about lambda calculus – PhD Nov 28 '16 at 22:13
• I think the core of your question is if complexity could be developed using lambda calculus. The answer is yes, and there is an old question asking that on the site iirc. – Kaveh Nov 29 '16 at 3:36

You may wish to look at cost semantics for functional languages. These are various computational complexity measures for functional languages that do not pass through any kind of Turing machine, RAM machine, etc. A good place to start looking is this Lambda the Ultimate post, which has some good further references.

Section 7.4 of Bob Harper's Practical Foundations for Programming Languages explains the costs semantics.

The paper On the relative usefulness of fireballs by Accattoli and Coen shows that $\lambda$-calculus has at most linear blowup with respect to RAM machine model.

In summary, on this other planet things would be pretty much the same with regards to NP, but there would be fewer buffer overflows, and there wouldn't be as much garbage lying around.

• I suppose the untyped $\lambda$-calculus people would still invent (pure) scheme. Oh well. – Andrej Bauer Nov 28 '16 at 22:00
• That's a nice link on the LtU post. But any links to concrete examples of proving this class of "NP" with problems like 3Sat? Curios to see a "proof" in lambda calculus – PhD Nov 28 '16 at 22:16
• Damiano, you could post your comments as a proper answer which demonstrates that one can do NP-related theory directly in $\lambda$-calculus. – Andrej Bauer Dec 1 '16 at 18:30
• @DamianoMazza - I agree with Andrej and believe your comment should be an answer – PhD Dec 5 '16 at 1:25
• @Andrej: Done! I removed my previous comments. – Damiano Mazza Dec 5 '16 at 12:16

At the request of Andrej and PhD, I am turning my comment into an answer, with apologies for self-advertising.

I recently wrote a paper in which I look at how to prove the Cook-Levin theorem ($\mathsf{NP}$-completeness of SAT) using a functional language (a variant of the λ-calculus) instead of Turing machines. A summary:

• the key notion is that of affine approximations, i.e., approximating arbitrary programs by affine ones (which may use their inputs at most once); the intuition is that $$\frac{\text{Boolean circuits}}{\text{Turing machines}}=\frac{\text{affine \lambda-terms}}{\text{\lambda-terms}}$$ so affine $\lambda$-terms approximate arbitrary computations arbitrary well just like Boolean circuits;
• the upshot is that, in the $\lambda$-calculus world, the proof is much "higher-level", it uses order theory, Scott-continuity, etc. instead of hacking Boolean circuits; in particular, the slogan "computation is local" (which is given by many as the message underlying the Cook-Levin theorem) becomes "computation is continuous", as expected;
• however, the "natural" $\mathsf{NP}$-complete problem is not CIRCUIT SAT but HO CIRCUIT SAT, a kind of "solvability" of linear λ-terms or, more precisely, linear logic proof nets (which are like higher-order Boolean circuits);
• of course, one may then reduce HO CIRCUIT SAT to CIRCUIT SAT, thus proving the usual Cook-Levin theorem, and the gory, low-level details are all moved to building such a reduction.

So the only thing that would change "on this side of the planet" is, perhaps, that we would have considered a λ-calculus-related problem, instead of Boolean-circuit-related problem, to be the "primordial" $\mathsf{NP}$-complete problem.

A side note: the above-mentioned proof could be reformulated in a variant of Accattoli's $\lambda$-calculus with linear explicit substitutions mentioned in Andrej's answer, which is perhaps more standard than the $\lambda$-calculus I use in my paper.

Later edit: my answer was just a bit more than a cut-and-paste from my comment and I realize that something more should be said concerning the heart of the question which, as I understand it, is: would it be possible to develop the theory of $\mathsf{NP}$-completeness without Turing machines?

I agree with Kaveh's comment: the answer is yes, but perhaps only restrospectively. That is, when it comes to complexity (counting time and space), Turing machines are unbeatable in simplicity, the cost model is self-evident for time and almost self-evident for space. In the $\lambda$-calculus, things are far less evident: time cost models as those mentioned by Andrej and given in Harper's book are from the mid-90s, space cost models are still almost non-existing (I am aware of essentially one work published in 2008).

So, of course we can do everything using the purely functional perspective, but it is hard to imagine an alternative universe in which Hartmanis and Stearns define complexity classes using $\lambda$-terms and, 30 to 50 years later, people start adapting their work to Turing machines.

Then, as Kaveh points out, there is the "social" aspect: people were convinced that $\mathsf{NP}$-completeness is important because Cook proved that a problem considered to be central in a widely studied field (theorem proving) is $\mathsf{NP}$-complete (or, in more modern terminology, using Karp reductions, $\mathsf{coNP}$-complete). Although the above shows that this may be done in the $\lambda$-calculus, maybe it would not be the most immediate thing to do (I have my reserves on this point but let's not make this post too long).

Last but not least, it is worth observing that, even in my work mentioned above, when I show that HO CIRCUIT SAT may be reduced to CIRCUIT SAT, I do not explicitly show a $\lambda$-term computing the reduction and prove that it always normalizes in a polynomial number of leftmost reduction steps; I just show that there is an algorithm which, intuitively, may be implemented in polynomial time, just like any complexity theorist would not explicitly build a Turing machine and prove it polytime (which, let me say it, would be even crazier than writing down a $\lambda$-term, let alone check for mistakes).

This phenomenon is pervasive in logic and computability theory, complexity theory just inherits it: formal systems and models of computation are often used only to know that one can formalize intuitions; after that, intuition alone is almost always enough (as long as used carefully). So reasoning about the difficulty of solving problems like SAT, TAUT, SUBSET SUM, GI etc., and thus developing the theory of $\mathsf{NP}$-completeness, may largely be done independently of the underlying computational model, as long as a reasonable cost model is found. The $\lambda$-calculus, Turing machines or Brainfuck programs, it doesn't really matter if you know that your intuitions are sound. Turing machines gave an immediate, workable answer, and people didn't (and still do not) feel the need to go further.

• Just a clarification many miss: Steve proved NP-completeness for TAUT, the proof for SAT is implicit there in there. The notion of Karp reduction did not exist at the time. It is also important to note that TAUT was the reason why Steve got interested in the topic and is central to automatic theorem proving, would people be as interested in solvability of linear lambda terms? The alternative development is possible, but would it happen without the foreknowledge of NP-completeness? I find that unlikely considering that the alternative development is rather recent. :) – Kaveh Dec 5 '16 at 18:51
• I remember reading somewhere that part of Levin's motivation to develop NP-completeness was the inability to solve Graph Isomorphism and Minimum Circuit Size Problem (MCSP), and the hope to show that they were (what we would now call) NP-hard. At least GI would've still existed in a world of lambdas... – Joshua Grochow Dec 6 '16 at 3:19
• @Kaveh, thanks for your comment, I added some paragraphs to complete the answer. – Damiano Mazza Dec 6 '16 at 10:25
• @Josh, so would TAUT and SAT. – Kaveh Dec 7 '16 at 9:26