11
$\begingroup$

On mathoverflow, there is a logic question (the details are not particularly relevant) and a user makes the following remarks in a reply:

...modern programming languages are type theories -- so assertions about whether all programs in a given language are total or not can boil down to assertions about the existence of large cardinals. Meta-mathematically, this is a trivial point, but often people don't immediately see that large cardinals amount to facts about the termination of computer programs. - Neel Krishnaswami

Almost two years ago now a user leaves a comment:

This is very interesting. Which large cardinals are used in this way? Can anyone point me to a reference?

And last month, another user leaves a comment:

Is there any reference for the relation between large cardinals and termination of programs in a specific programing language?

My question is inline with the unanswered comments, namely, can anyone explain the relationship between large cardinals and program termination?

(I'm not sure the proper tags to include. Type theory? Compuational complexity? Foundations? Please edit or comment for more appropriate tags)

$\endgroup$

2 Answers 2

6
$\begingroup$

This isn't really an answer, but it's way way too long for a comment. I just want to offer some commentary on the linked answer. Re: your actual questions, you might find this paper interesting.

I think that Neel's$^*$ comment is somewhat misleading.

Let's start from the basic side of things: how do large cardinals imply facts about arithmetic? (Via Godelization, facts about program behavior are "really" facts about arithmetic.) The simplest answer is via consistency claims. The statement "ZFC is consistent" is a $\Pi^0_1$ sentence (look up the arithmetic hierarchy if you're not already familiar with it). It is also implied (over ZFC) by the existence of a weakly inaccessible cardinal; this is because ZFC proves the statement "If $\alpha$ is weakly inaccessible, then $L_\alpha\models$ ZFC." So this is an example of a fact about arithmetic which is implied by a large cardinal statement.

This can be directly turned into a statement about program termination, as follows. For a given computably axiomatizable theory $T$ (such as ZFC), we can write a program $\pi_T$ which halts iff $T$ is inconsistent - basically, $\pi_T$ just searches for a proof of a contradiction from $T$, and halts iff it finds one.

As an aside: the task of finding reasonably small programs which "represent" certain properties of a given theory, or at least have meaningful properties which can't be proved in a given theory, is an interesting one. See e.g. this work by Aaronson and Yedidia on a short program which runs forever, but which ZFC can't prove runs forever.

Essentially, the following is a basic fact about computability and provability:

The consistency of a given computably axiomatizable theory $T$ is equivalent to the non-termination of a program associated to $T$, and consistency statements often follow from large cardinals.

So that's a sense in which large cardinals can lead to statements about the behavior of programs. It's even better than that: the program $\pi_T$ associated to $T$ is optimal, in the sense that a reasonable theory (much much less than ZFC - even less than PA!) proves that $\pi_T$ terminates iff $T$ is inconsistent. In particular, to each large cardinal axiom A we can associate a program $\sigma_A$ such that $\sigma_A$ terminates iff ZFC+A is inconsistent. So:

The consistency with ZFC of a given large cardinal axiom is equivalent to the non-termination of a certain program.

So this connects the consistency of large cardinals with the non-termination of programs.


But that's not what Neel said! He said that large cardinals were equivalent to statements about program termination.

Now on the face of it, this is outright false: statements about program termination are arithmetic statements, and these can't depend on the actual truth of large cardinal axioms. Precisely, if A is (what would generally be recognized as) a large cardinal axiom, then ZFC does not prove "$\varphi$ is equivalent to A" - or even "$\varphi$ implies A" for any arithmetic sentence $\varphi$ unless ZFC actually disproves A.

This may sound mysterious, but there's actually much less to it than meets the eye. Fix a large cardinal axiom A = "there is a cardinal $\kappa$ such that [stuff]." The [stuff] will always imply that such a $\kappa$ gives a model of ZFC, that is, that $L_\kappa\models$ ZFC (this is a sociological claim about what constitutes a "large cardinal" - the term "large cardinal" is not a precise one).

OK, so suppose ZFC doesn't disprove A. Then by Godel's completeness theorem, ZFC + A has a model $M$. Now let $\kappa$ be the least ordinal in $M$ such that either $M\models$[stuff]$(\kappa)$ or for some $\alpha\in Ord^M$, $\kappa\in L_\alpha^M$ and $L_\alpha^M\models$[stuff]$(\kappa)$. (This isn't necessarily the actual least witness to A - it could be smaller.) By the note above, we have $L_\kappa^M\models$ ZFC, but by definition of $\kappa$ we also have $L_\kappa^M\not\models$ A. However, the set of natural numbers didn't change between $M$ and $L_\kappa^M$ (since all we did was "cut (the $L$ of) $M$ off" at some infinite level), so $L_\kappa^M$ satisfies all the same arithmetic facts as $M$ itself - in particular, the truth value of $\varphi$ didn't change. So we've shown:

If A is a large cardinal axiom and $\varphi$ is an arithmetic sentence consistent (over ZFC) with A, then $\varphi$ doesn't prove A.

And the case when $\varphi$ isn't consistent (over ZFC) with A is of course trivial, since then $\varphi$ can't be equivalent (over ZFC) with A unless A is inconsistent.


So in what sense was Neel's claim correct?

I think he was making a point about the semantics of programming languages. This is not a subject I know much about, so I may be wrong here, but my understanding is as follows:

The idea here is to create an actual mathematical structure associated to a given programming language. My understanding is that often, if not usually, this structure is a category with various nice properties and possibly additional structure. Incidentally, the precise details of the structure can be subtle - see e.g. this discussion of whether the "categorical" semantics for Haskell actually is a category. (I am totally unqualified to comment on this specific issue, by the way. If you're interested you might ask a question here about it.)

The point now is that the following can, and apparently does, occur:

There is a semantics $\mathcal{S}$ for a programming language FOO, such that the non-termination of certain programs in FOO are equivalent to the existence of certain corresponding large cardinal axioms, appropriately re-interpreted into the relevant framework, in the structure $\mathcal{S}$.

That is, the construction of $\mathcal{S}$ from FOO is somehow canonical, and we're not speaking of the non-termination claim as implying the genuine existence of a large cardinal, but rather as implying a fact about the internal structure of the object $\mathcal{S}$.

Note the phrase "appropriately re-interpreted." A large cardinal axiom stated in the language of set theory doesn't immediately make sense in the context of, say, category theory. Instead, we need to look for an appropriate equivalent. A neat example of this is the equivalence, due to Blass, of the existence of a measurable cardinal and the existence of an exact functor $F$ from Sets to Sets which isn't naturally equivalent to the identity. Now, if we're given some "appropriate" category $\mathcal{C}$, it perhaps makes sense to say "$\mathcal{C}$ thinks there is a measurable cardinal" iff the statement "there is an exact functor $\mathcal{C}\rightarrow\mathcal{C}$ not equivalent to the identity" is true.

So I suspect that this is what Neel means when he says that claims about termination are equivalent to set-theoretic claims: that when we look at the canonical semantics for a given programming language, termination facts are reflected by internal set-theoretic properties of that structure.


$^*$I'm not sure what the etiquette is regarding names; I've used first name, but I'm happy to use full name or professional title or etc. if that's the better standard.

$\endgroup$
6
  • $\begingroup$ While the categorical semantics (or any semantics) for a programming language can be quite subtle, the article by Andrej Bauer about Haskell is talking about whether Haskell can be viewed as a category in a rather naive way. This is not what is usually meant by a "categorical semantics". A rough analogy would be like asking whether syntactic arithmetical expressions form a group with the syntactic + being the group operation. (They don't unless we quotient or interpret, corresponding to Bauer's 1 and 3. For "Hask", 1 isn't clearly defined and the "obvious" choice doesn't work.) $\endgroup$ Commented Jan 27, 2018 at 13:22
  • $\begingroup$ I keep coming back to this answer every couple of days because I have a followup question but I can't quite work out what I'm trying to ask -- something like, "Is there a relationship (equivalence?) between the halting problem and the existence of large cardinals?" Does it even make sense to ask that, or perhaps there are some assumptions needed first, like choosing some model ... $\endgroup$
    – Burnsba
    Commented Feb 16, 2018 at 14:29
  • $\begingroup$ @Burnsba There is no direct relationship between the halting problem and the existence of large cardinals, but there is a direct relationship between the halting problem and the consistency of large cardinals. For any (computably axiomatized) theory $T$ there is a Turing machine $\Phi_T$ which halts on input $0$ iff $T$ is inconsistent ($\Phi_T$ just searches for a proof of a contradiction in $T$, and halts iff it finds one). Now take $T$ to be ZFC + [your favorite large cardinal axiom]. $\endgroup$ Commented Feb 16, 2018 at 16:22
  • $\begingroup$ Remember, as I said in my answer, that basic facts about the halting problem (like "is $17$ in the halting problem?") are arithmetic - any two models of set theory with the same natural numbers will agree on the answer. So e.g. if $M$ thinks "$17$ is in the halting problem" and $M$ has an inaccessible, let $N$ be $(V_\kappa)^M$ (where $\kappa$ is the least inaccessible in $M$); $N$ is a model of ZFC and $M$ and $N$ have the same natural numbers, so $N$ thinks "$17$ is in the halting problem," but $N$ doesn't have an inaccessible. (cont'd) $\endgroup$ Commented Feb 16, 2018 at 16:25
  • $\begingroup$ So "$17$" is in the halting problem" doesn't imply that any large cardinals exist. Now there is a more subtle thing going on here: by virtue of Godel's completeness theorem, if ZFC+[large cardinal axiom] is consistent then it has a model. So we can ask, not about connections between arithmetic facts and the existence of large cardinals in the actual universe, but about connections between arithmetic facts and the existence of particularly nice ("canonical") structures with large cardinals. This was the point I was getting at in the final section of my answer. $\endgroup$ Commented Feb 16, 2018 at 16:28
1
$\begingroup$

I think the comment you quote means less than you think it does.

First of all, it's not about whether individual programs terminate, but whether all programs in a given programming language terminate. This is often a trivial question: In every actually used general-purpose programming language it is pretty clear that of course there's a way to write an infinite loop.

There are also non-general programming languages that are deliberately designed such that they only allow terminating programs to be written. As we all know, this comes at a cost: there will inevitably be total recursive functions that the language cannot express.

Neel is/was apparently engaged in pushing the boundaries of that: finding a way to define a programming language such that all valid programs terminate, and yet a usefully large class of functions can be written in a reasonably straightforward way. When he says "modern programming languages are type theories", he's expressing hope/belief that good solutions to that problem will come as an integrated result of the language's type system -- the rules that prevent a program from doing nonsensical/dangerous things like treating a number from its input like a memory address -- rather than a bolt-on static analysis that exists only to verify that programs are total. These type systems are closely related to type theories in logic and category theory.

(Note that for practical purposes a language that guarantees just that everything is total is of questionable utility: if you're running code you got from an untrusted source and want to be sure they didn't trick you into running something that never terminates, you also want to be sure that they won't trick you into trying to calculate Graham's number in base 23, even though that is theoretically a terminating task).

What Neel seems to be saying is that some of the proposed solutions have the property that ZFC cannot prove that they work (as in, that all valid programs in such-and-such system terminates), but that ZFC plus such and such often-accepted large cardinal assumption can.

He's probably not, in light of Noah's arguments, asserting that "this type system works" implies that such and such large cardinal must exist. But it is conceivable that he can prove "this type system works" equivalent to "such and such large cardinal axiom is relatively consistent with ZFC". These are both statements of the same general flavor (there are solid connections between consistency of logics and totality of programming languages, e.g. via the Curry-Howard correspondence), so it wouldn't be outrageous for them to imply each other.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .