You're reading the public-facing archive of the Category Theory Zulip server.
To join the server you need an invite. Anybody can get an invite by contacting Matteo Capucci at name dot surname at gmail dot com.
For all things related to this archive refer to the same person.
Are you all requiring function extensionality (not just eta) for both -> and forall in your definition of model for system F? I usually don't but some of these older papers do
I wouldn't.
Section 3 of Tannen Coquand ('Extensional Models for Polymorphism', https://repository.upenn.edu/server/api/core/bitstreams/4eed61a9-05c6-453e-be1e-58b5f5f47bbd/content) gives a (the?) closed term model of system F, shows that it is not extensional, and shows how you can quotient it to get extensionality (section 4). (That it satisfies betais stated earlier on page 11.) So it seems like the closed term model may be parametric but not extensional, if that's even possible? Anyway, is the Tannen Coquand model equivalent to what people understand as the system F term model? FWIW I think both this thread and the HRR conclusion paragraph use "true in the term model" accidentally instead of "true in all models/provable from beta/eta alone" in many places
Hang on, I don't even know what funext means in a non-dependent type theory.
Oh, do you mean the axioms on p12 of TC, that functions are determined by their action on "elements"? That doesn't even make sense for a category theoretic model where types don't have "elements".
You could interpret elements as global elements i.e. maps from the terminal object, which in the term model are closed terms, but I certainly wouldn't expect functions in the term model to be determined by their action on closed terms.
The paper writes the condition semantically, but you can just as easily add proof rules to the system F calculus (from x:T |- f x = g x for fresh var x infer |- f = g), which is usually what I've seen
That's a different condition, that's just eta-conversion.
I do not believe funext and eta are equivalent here, or even in dependent type theories, although eta is a special case of funext
Ryan Wisnesky said:
I think both this thread and the HRR conclusion paragraph use "true in the term model" accidentally instead of "true in all models/provable from beta/eta alone" in many places
Those should always be the same. That's part of the point of the term model, that it satisfies only the provable equations and hence gives you completeness of the semantics.
Ryan Wisnesky said:
I do not believe funext and eta are equivalent here, or even in dependent type theories, although eta is a special case of funext
Correct. But this rule:
is eta, not funext.
(As long as means definitional equality, and in a non-dependent type theory there's nothing else for it to mean.)
hm, I grabbed the phrasing from Coq: Lemma functional_extensionality {A B} (f g : A -> B) :
(forall x, f x = g x) -> f = g. What did I do wrong? (it's a lemma b/c uses the dependent ext axiom)
also: the term model should satisfy a lot more equations than just what is provable in the rules for system F. (The Tannen Coquand paper talks about this a bit). For example, the term model of O:nat and S:nat->nat and + proves x+y=y+x for variable x, whereas an arbitrary model does not. (at least if we're talking in Set, following Baader and Nipkow.). I thought this was the reason initial model semantics was "good" - you get all these extra properties not found in arbitrary models.
Ryan Wisnesky said:
hm, I grabbed the phrasing from Coq: Lemma functional_extensionality {A B} (f g : A -> B) : (forall x, f x = g x) -> f = g. What did I do wrong? (it's a lemma b/c uses the dependent ext axiom)
In that axiom =
means propositional equality.
Ryan Wisnesky said:
For example, the term model of O:nat and S:nat->nat and + proves x+y=y+x for variable x, whereas an arbitrary model does not.
Not in any term model I'm familiar with. What is your definition of "term model"? I have always understood the term model to consist by definition of the terms modulo definitional equality.
Remember we are talking about term models with open terms.
It looks to me like that's exactly what TC do in their section 3.
They don't call it a "model" because they want to save that word for something that satisfies their additional semantic extensionality property, which of course the term model doesn't. But their section 3 is really the "term model".
I'm following Baader and Nipkow re: term algebras.
Screenshot 2025-07-03 at 1.46.44 PM.png
Screenshot 2025-07-03 at 1.48.37 PM.png
Screenshot 2025-07-03 at 1.48.28 PM.png
Screenshot 2025-07-03 at 1.47.58 PM.png
Screenshot 2025-07-03 at 1.47.32 PM.png
example 3.5.9 shows there are equations that hold in the term algebra that don't hold in arbitrary algebras
Screenshot 2025-07-03 at 1.53.58 PM.png
Baader and Nipkow even define and name the theory of the term model (showing it is more than just the theory started with)
Mike Shulman said:
Remember we are talking about term models with open terms.
I thought the TC section 3 builds a model out of closed terms? that's why they need all the environment machinery?
Screenshot 2025-07-03 at 1.59.15 PM.png
In a theory with function-types, you can get away with using only closed terms because an open term can be abstracted over its free variables to yield a closed term.
certainly they claim in the conclusion that their model "C" is made entirely of closed terms
But for instance the observation you quoted about is not true in a term model with open terms, if and are free variables.
sure, but I don't see how TC section 3 has free variables or open terms anywhere in its definition. This is why I think the term model for system F should have all kinds of equations true in it that aren't implied by the theory of F. The interpretation of a sequent that has variables in context uses the "environment" rather than an open term (a trick from closed term models of simply typed lambda calculus). I'd also be surprised they'd call it the "closed term/closed type construction" if it used open terms.
I will agree that a model of system F with open terms as carrier will prove a lot less things than one with closed terms as carrier, according to my intuition
Okay, let's back up. Really explaining this in depth is going to require a broader view.
I'm going to write to Prof Tannen. I think he might be able to settle some questions (eg is there an equation true in his term model of system F that doesn't follow from beta/eta) faster than us trying to work through his definitions
(The answer to that specific question is that it depends on what you mean by "equation" and "true", which I'll get to in a bit.)
I do want to keep pressing on the (a?) closed term model of system F (instead of the open model), however, because to me that is what formalizes "idealized haskell w/o recursion"; it's what I have in my head when I write a big step operational semantics (the target is the closed term model)
Every theory is written in a "doctrine" that specifies the allowable judgment forms. You can extend a theory to a more expressive doctrine, and we often blur the distinction between a theory and its extension, but formally they are different and it's sometimes important to distinguish.
In particular, the term model of a theory is built out of the judgment forms that are derivable in its syntax. But what those are depends also on the doctrine, and thus the term model for a theory is different depending on what doctrine you write it in.
Theories like STLC and System F are written in doctrines whose judgment forms include contexts of variables, such as . Thus, their term models are built out of judgments of that sort, which are of course open terms.
The doctrine of STLC, with only "term variables", can be called "simple type theory", while the doctrine of System F, which also has type variables, could be called "polymorphic type theory".
well sure, the closed term model of TC interprets judgements with variables in context, but the carrier for their interpretation is not open terms
Let me finish please.
The term model of a simple type theory is most directly viewed as some kind of multicategory, whose objects are the types and whose multi-morphisms such as are terms . However, it's common to view it instead as an ordinary category whose objects are contexts (lists of types), and whose morphisms are substitutions (lists of terms).
If the theory has product types, this is equivalent to a category whose objects are single types and whose morphisms are terms in a singleton context such as . And even if the theory doesn't have product types, we can consider that category for simplicity.
If the theory has function types, then there is a bijection between open terms such as and closed terms of type . Thus, in this case we could equivalently build the term model using only closed terms. This is what TC do in section 3, modulo some rearranging of their presentation to become a category, and ignoring the relation which I haven't gotten to yet.
In particular, the equality between terms in the section 3 model is the equivalence relation that they call , which is defined to be the definitional equality of syntax. Thus, their term model qua category, like every term model, validates all and only the statements in the doctrine that are derivable in the theory.
So what about .
In general it is true that a term model can satisfy additional statements that are not in its doctrine.
in Baader-Nipkow example 3.5.9, the extra equations it satisfies are not part of the doctrine of the original equational theory?
Right!
Ok, I'll need to pause to consider that. I've never really used doctrines before, and Baader/Nipkow don't talk about that point at all
If we formulate a simple algebraic theory in a doctrine without contexts, there is just one judgment , with rules such as
(Doctrines are indeed under-explained!)
here you are talking about ground terms only (b/c no contexts)?
Exactly.
Then the term model in this doctrine is the set of all ("closed") terms such as built only from the constants and no "variables".
right
A statement like "for all and we have " is not in this doctrine, and so it can hold in the term model even though it isn't "derivable from the theory".
However, we can also extend this theory to the doctrine of a simple type theory with judgments in context like and , where is the unique type. In this case, the term model will be the (multi)category freely generated by a semigroup object containing two elements that commute with each other. Of course such a semigroup need not be abelian, and therefore the two morphisms determined by the terms and are not the same, and so this term model does not satisfy the equation , which is in its doctrine.
right, I'm still following. But for example 3.5.9, why isn't that equation that is only true in the term model not in the original doctrine (which had variables in context in its initial set of equations)
It will satisfy a statement like "for all closed terms and we have ", but this is not in its doctrine, since simple type theory does not include a way to quantify over closed terms.
(also, I understand why function extensionality as I wrote it doesn't fit with system's F equational logic (it just follows from eta), albeit not b/c of a hyper doctrine reason. I'd never tried writing fun-ext outside of coq before)
Ryan Wisnesky said:
But for example 3.5.9, why isn't that equation that is only true in the term model not in the original doctrine (which had variables in context in its initial set of equations)
Yes, good point. If we want to capture that whole example in a doctrine without contexts, we would have to include associativity in the doctrine itself rather than in the theory. So it would be in the doctrine of semigroups, and the theory in that doctrine would be the theory of two commuting elements, and so the term model would be the free semigroup generated by two commuting elements. (This is just like how associativity for morphism composition in a category, i.e. substitution of terms, is included in the doctrine of simple type theory, but not expressible in any theory in that doctrine.)
So, to conclude, the TC relation is a way of expressing statements about closed terms, which is not in the doctrine of simple type theory, and so the term model can satisfy statements of that form that are not derivable from the theory.
ooh, heh, I get it now... I think. the "doctrine" defines what freeness is relative to. In which case, example 3.5.9 is "different" when you view it as the three axiom equational theory over the empty theory (as I do), or as a single ground equation over two (universally quantified) equations... right?
Yes!
I wrote a longish blog post about doctrines, and more general "-theories", here.
ok, that explains (some of) the confusion with term models. For me (and I'd imagine TC), we just assume every statement in first order logic about the model is fair game to distinguish the models
incidentally, CQL may provide a good example of "stacking" doctrines, its "instances" are theories in the doctrine of its schema which is a theory in the doctrine of its "typeside", if I understand correctly. Implementation-wise these are just theories that extend each other, but there are very specific rules about what kind of equations can be written where in this stack.
The confusion is that the TC syntax for looks the same as the syntax for definitional equality in the doctrine. It would be better if instead of they wrote something like .
Yes, a doctrine is a 2-theory, which is a 2-theory in some 2-doctrine (= 3-theory), and so on.
I think im still going to write to prof. tannen asking about properties true in his closed term model that don't follow from beta/eta, but then we can check them to see if they fall into the expected doctrine or not. does that sound like a good next step?
What's the goal?
I want to know if HRR's Q = S is true in the closed TC model, even if that question is ill-posed doctrinally. It's true in the closed TC model after they collapse it, because collapse creates a PER model
Do they say that?
no one has made that claim, it's a claim I need to figure out to check my understanding
I mean, do they claim that it's true after the collapse?
I think they say collapse results in a PER somewhere, I'll go find the reference
I want to not be too blithe about it, because there could be multiple meanings of what "being a PER model" is, and it doesn't seem to me that simply quotienting the term model could create the kind of "PER model" that makes Q=S.
lemma 4.3 says something is a PER, although maybe not the kind of PER HRR talk about
I'll ask prof tannen the question both pre-collapse and post-collapse
Okay. Pre-collapse we know that it is not true in the ordinary sense as a statement about the term model qua category, because of the HRR counterexample. But I guess there may be a way to interpret it as a different statement involving , which might be true.
my hunch is all these properties that are ruled out doctrinally actually do conspire to equate Q=S in the specific closed term model of TC, and HRR meant open term model or "all models"
I'm not sure what you mean by hyper-doctrinally. I haven't been talking about any hyperdoctrines.
oh, sorry, I've been saying hyper doctrine on accident, I just mean "doctrine"
I also don't know what you mean by distinguishing the closed term model and open term model. As I said, I think there is no difference between them in a theory with function types; what makes the difference is what's in the doctrine.
Oh, I see. It's very confusing that a "hyperdoctrine" is totally unrelated to a "doctrine" in this sense.
I'll find the reference - I think it was hasegawa - who was talking about the differences between the open and closed term models of system F
Screenshot 2025-07-03 at 4.53.29 PM.png
Yeah, it hasegawa (Parametricity of extensionally collapsed term models of polymorphism and their categorical properties) from here: https://link.springer.com/chapter/10.1007/3-540-54415-1_61 . so a priori I claim open and closed models can be different, even if those differences may not be visible doctrinally. Paper attached
3-540-54415-1_61.pdf. It also "proves" an identity extension lemma without giving the proof
while we're revisiting very basic assumptions, I always thought the logical relations lemma was proved by induction on closed terms or types, so it surprises me when a closed term model isn't parametric. but as this thread makes clear, I'm full of erroneous assumptions if someone wants to correct this one too
I can't get to that paper either, so I don't know what this putative closed term model might mean. But I do know that it's nearly impossible to prove anything by induction only over closed terms: when you get to the case for , you don't have an inductive hypothesis since isn't a closed term any more. The logical relations lemma that I know is proved by induction (i.e. by the universal property) on the ordinary (open) term model. (And, remember that that's only external parametricity.)
Oh, I see you attached the paper now, let me see.
fyi: hasegawa's remark 4.8 mentions something quite similar to HRR's a ~ CPS a
Well, I can't make heads or tails of Hasegawa's introduction, and nowhere in the paper do I see a definition of what he means by a model of open terms. His model of "closed terms" (which he calls just an "interpretation") looks to me like it is equivalent to I would call the ordinary term model, by the trick that I mentioned of abstracting open terms to make them closed.
Ohh... maybe by "open terms" he means a model in which the "elements" of a type are the union of the terms of that type in all contexts? Or, put more categorically, in which the morphisms are terms of the form for some additional context , which could be different for different morphisms ?
I've seen people do things like that for untyped lambda-calculus, so maybe people do it for typed lambda-calculus too. It certainly wouldn't be the initial model, but it might be useful for some things.
if the trick of an interpreting a term in context via its corresponding closed lambda term really set up an equivalence of models, why would the closed one fail to be extensional but the open would not? my intuition is that these closed models must be doing something differently than just using the equivalent lambda term or there wouldn't be all these papers by well-known authors about how to turn the closed model extensional... but we might be approaching the point where it's easiest to ask the authors
It's an equivalence between what TC and Hasegawa call the "closed term model" and what I call "the term model" which involves terms in context that only use the variables from that context. I don't think the latter is what Hasegawa means by an "open term model" -- I think he means what I suggested above, where the terms can also involve additional free variables that aren't in the context. That model can be "extensional" for trivial reasons because you can always apply two functions to a free variable and then if it must be that by eta.
I renamed this discussion because it has veered far from the original topic of comparing synthetic algebraic geometry to continuations. This deviation happened at the beginning of the discussion once it became clear that the SQC axiom wasn't all that similar to the axioms that types are isomorphic to its continuations.
I found and attached the paper hasegawa cites when he says "the open model is used to prove completeness". section 3 uses an argument like you just made, but I can't settle your question from reading it quite yet.
second-order-semantics.pdf
Screenshot 2025-07-05 at 4.39.55 PM.png
Screenshot 2025-07-05 at 4.40.33 PM.png
I'm still trying to square the fact that the term model of the simply typed lambda calculus is sound and complete for the equational theory of the STLC (I've gone through this proof many times), but that you can, according to Baader/Nipkow/Mitchell and many others, still end up with a "term model" of an equational theory that has more equations true in it than specified (and that this fact is used in algebraic specification, for example, you can choose from 'initial model' and 'final model' semantics, with entire papers about the differences). doctrines may help formalize what's going on, but I'm getting more confused rather than less. I've included some images from Baader/Nipkow that indicate whatever is going on is related to having infinitely many variables, and also an image of Mitchell talking about how "no junk, no confusion" in the initial model refers to ground terms (not open terms). I'll keep thinking, but if anyone can explain this difference, please chime in. the difference is even weirder in my mind when I consider the point-free form of the STLC, since that has no variables and so should be amendable to analysis from universal algebra.
Screenshot 2025-07-05 at 5.03.03 PM.png
Screenshot 2025-07-05 at 5.02.56 PM.png
I think the remark in 3.5.8 means that b/c example 3.5.9 uses quantified equations, its ground term model may satisfy quantified equations that are not provable from the original equational theory (as the example shows), and that this is a general phenomenon - ground models of quantified equations will have many more (quantified) consequences than models with variables. which is the "usual situation" where I grew up - ground term models of theories with variables. but I get why this situation isn't fully satisfactory for all times, and why you'd want variables in your term model.
Yes, we already discussed that -- BN's initial algebras are in a doctrine without contexts, while the "identities" they consider are in a nonempty context.
never having used doctrines before, I have to work all this out in BN/mitchell terms, and I'm being very careful anticipating writing this up, thanks for sticking with me
The thing about cardinality of variables is an extension of that: if instead of the initial algebra () you consider the free algebra on a set of generators , then any equation in a context of length can be instantiated using distinct generators for the variables, and since it's free on the generators it won't satisfy any such equations that don't follow from the theory even with contexts.
this new set of messages is about how the term model of the STLC manages to avoid this phenomenon, b/c I thought you could encode the point-free version of STLC equationally
By "point-free STLC" do you mean combinatory algebra?
pretty much
SKI stuff?
that kind of thing, but more for the internal language of a CCC
I'll go find a definition
oh, think "curry-howard-lambeck", if that helps
Not really for me.
You can do typed combinatory algebra without any problem.
if that's what you mean by "internal language of a CCC"
E.g. exercise 2.8.2 of my categorical logic notes
Screenshot 2025-07-05 at 5.32.10 PM.png
this is for a BCCC and some other stuff, but it's the language with "curry" and "eval" etc - the original "categorical machine language", actually
What I'd need to see to understand that is the typing judgments, not the raw terms.
Screenshot 2025-07-05 at 5.33.24 PM.png
here's wikipedia's definition
they are here
https://en.wikipedia.org/wiki/Curry–Howard_correspondence#Curry–Howard–Lambek_correspondence
so specifically, assuming these "equations" are actually equations the sense of Baader Nipkow, I'm trying to compare its ground term model against the usual one for STLC that is sound/complete for beta/eta only
They should be the same, since both present a free CCC.
The analogue of the BN observation about "extra equations" would apply here to equations of the form in a context where you've assumed a couple of morphisms in the free CCC, which is not a statement in the variable-free doctrine of this theory.
the ground term model of the equations suffers from the phenomenon that it will have quantified equations true in it that don't follow from the equations (according to BN 3.5.8 remark). But the free CC is sound/complete for the equations. that's the contradiction I don't understand
If you pass that back to ordinary STLC with variables, you would get something like , which is also not in the doctrine of STLC since it quantifies not over internal variables but over judgments.
And hence the term model isn't complete for equations of that form either.
ok, I see now doctrines really are formalizing what's going on here
er, I don't understand doctrines at all, but I understand "forms of syntax"
what happens if we just roll with it. like, are there "extra equations" that hold in the ground term model but not in the usual model? I see how "extra equations" they can be consider ill-formed, but for other purposes, they are still well-formed. like, they seem to have determine truth-values (being true or false in each model)? I ask because to my understanding of "haskellers", for blog post purposes these extra equations may be part of "Haskell's term model"
hm, I also don't understand why "passing back" does anything at all - the original equation with x and y seems like it is already an equation of ordinary STLC, but that may be because of lack of knowledge of doctrines. in fact, conflating the two may be another common mistake to write about
I don't know what you mean by distinguishing a "ground term model" from a "usual model". Each theory in a given doctrine has a definite specific term model.
By "the usual model", I mean the free CCC as defined in sec 7/8 of https://www.cl.cam.ac.uk/teaching/1617/L108/catl-notes.pdf . By "the ground term model", I mean the ground term model of the "lambeck" form of STLC (with curry, eval, etc) from wikipedia
I'd like to find an example of an "extra equation" that holds in the ground term model that does not hold in the usual model, which I claim is possible since "quantification over judgements" is still well-defined, if not internalized in the stlc
I thought I just explained that those two models are the same.
Each of them satisfies internally exactly the equations in their doctrine that are derivable from the theory, and each of them can satisfy additional equations that are not in the doctrine. The difference is that one of them has an "internal" notion of "variable" while the other is formulated without such, but there is still a bijection between the "internal" equations on both sides and also a bijection between the "external" equations on both sides.
if "each of them can satisfy additional equations that are not in the doctrine", then what is an example equation, not in the doctrine, that one satisfies that the other doesn't (that's my previous question), or must they satisfy the same set of equations not in the doctrine?
Ryan Wisnesky said:
never having used doctrines before,
This sounds a bit off because doctrines aren't mainly a technical device one "uses" in a problem like this - e.g., people have argued for many years about the correct definition of doctrine, but that doesn't stop anyone from talking about doctrines, because they mainly serve as a way of thinking that keeps one from getting confused. In this particular case Mike seems to keeps using them to say roughly "the stuff you do when you do logic with contexts is different from the stuff you do in logic without contexts, so just because something is initial when you're working without contexts, doesn't mean some similar-looking thing is gonna be initial when you're working with contexts". See, I said that without saying "doctrines", but Mike said it faster by saying the word "doctrines".
I don't understand what you guys are talking about, except for the part about how you gotta be careful which doctrine you're working in. It's a very general point, like how you can't say an object is initial until you've made up your mind what category it's an object in.
I think we're making progress, if testing Mike's patience. At present, there's two models of the simply typed lambda calculus we're trying to compare, one defined as the ground term model (in Baader Nipkow sense) of the "lambeck equations" as defined in wikipedia, the other being the free cartesian closed category as usual. These are so similar that teasing them apart (if they can be teased apart at all) may require what we've been calling "extra equations", which as I understand it can be formalized using doctrines
Ryan Wisnesky said:
if "each of them can satisfy additional equations that are not in the doctrine", then what is an example equation, not in the doctrine, that one satisfies that the other doesn't (that's my previous question), or must they satisfy the same set of equations not in the doctrine?
They must satisfy the same set of equations not in the doctrine because they are the same object.
heh, that would explain why I can't come up with an example myself and had to ask...
So you see, "teasing them apart" is mainly about teasing apart the two doctrines. So you gotta listen when people talk about doctrines, even if they never say exactly what a doctrine is in full generality (since nobody knows, although maybe Mike does).
I take the absence of an example here to mean that although a ground term model (in the BN sense) may satisfy extra equations, it doesn't have to, or any that it does are already true in the free CCC (which is I think is the case here, any "extra theorems" in the ground term model are true in the free CCC, following from the free CCCs initiality)
Is there a guy named Lambeck in addition to the famous guy named Lambek, or is this some joke about Lambek and Beck?
it's the famous guy
I'm a terrible speller
Okay: he's called Lambek.
fwiw, it sounds like much of the field of "algebraic specification", where you study the "extra equations" that arise in the ground term model of an equational theory, can be explained in doctrinal terms. there may be two blog posts here, one on folklore about system F and one about how doctrines relate to old school algebraic specification
bearing with me as I apply all of what happened today to the original questions about system F, I now conclude 1) Reynolds parametricity implies Q~Cont(Q) , and 2) the term model of system F is not reynolds-parametric (any "extra equations" from today can't "conspire to make it so", as was my original concern). I'd still like to find citations/proofs for these though. anyway, I have no further questions for now and will go back to writing.
I agree if instead of "parametric" you say internally parametric. I maintain the term model is externally parametric by the usual argument.
hm, I mean parametric in the sense of the HRR conclusion. I think they must have meant "internal" too, in which case they are saying its a failure of the externally parametric term model to be internally parametric, which squares with what we saw earlier with bridge discreteness etc. When put that way it doesn't seem surprising to me anymore
checking my understanding again: the plotkin-abadi identity extension lemma implies equality of two variables (rather than closed terms); therefore, the plotkin-abadi logic is axiomatizing internal parametricity. Nevermind: this was confirmed earlier in the thread
Ok, I've summarized my conclusions from this thread into the following list; some entries are sanity checks and some go against folklore, but all should be correct. the blog post will refer to many or most of these propositions. I don't have any more questions, and appreciate everyone's patience.
1) external parametricity does not imply q ~ cont q (evan,mike)
2) internal parametricity implies q ~ cont q (evan,mike)
3) internal parametricity implies c ~ cont c for every closed type c (b/c closed types are bridge discrete) (evan,mike)
4) internal parametricity doesnt imply a ~ cont a for variable a (internal parametricity of forall a, forall r, ((a->r)->r) does not help (mike); need bridge discreteness for a variable) (evan,mike)
5) system F term model is external but not internal parametric (HRR)
6) models of reynolds-abadi logic are internally parametric (mike)
7) external parametricity implies forall x, x -> x has one inhabitant (need reference)
8) the term model for system F is sound and complete for beta and eta (mike), same as with STLC (course notes)
9) "extra equations" (in the sense of BN) in the ground term model of the Lambek equational theory from wikipedia are meta-theoretic (not theoretic) statements about the free CCC that follow from initiality
10) extensional PER models are internally parametric (not 100% sure about this one / need reference)
11) in the early 90s many authors required models of system F to be extensional, a property they always expressed semantically (and different than eta) (tannen)
12) in the early 90s many authors distinguished between "open" and "closed" term models of system F for extensionality reasons, but "open" and "closed" may have unusual meanings in these papers (mike)
13) not all polymorphic functions in system F define natural transformations on definable functors (since not all type constructors are functorial, e.g. X |-> X->X) (reddy)
14) all polymorphic functions between (definable) functors are natural transformations in an internally parametric model, but not an externally parametric model (b/c q not iso to Cont q; need reference)
15) initial algebras and final coalgebras for positive defineable functors exist in an internally parametric model of system F (wadler)
16) eta implies a kind of function extensionality in system F (mike, mitchell)
17) in system F, both internal and external parametricity are meta-theoretic properties
18) internal parametricity (conclusions hold in all contexts) implies external parametricity (conclusions hold in empty contexts) for system F
Can you reformat that post please so the text will wrap?
Thanks! That's mostly right, but I have a few questions and quibbles.
(3) certainly depends on what theory we're talking about. It's not true in internally parametric dependent type theory, for instance, because universes are closed and not bridge-discrete. Evan showed essentially that all closed types in the first universe are bridge-discrete, which would imply that in a simple predicative type theory without universes all closed types are bridge-discrete; but his proof doesn't treat an impredicative universe or , so it's not clear to me at the moment whether all closed types in System F are bridge-discrete.
(7) I would say "one closed inhabitant".
(14) This depends on (3) (since automatic naturality for transfomations Reader->Id implies a ~ cont a), so it also varies with the theory, is false (or at least probably not true) for dependent type theory, and is unclear to me whether it's true for System F.
(16) What are you referring to here?
(17) I'm not sure what you mean by this for internal parametricity. Normally I think of internal parametricity as a built-in part of a theory, not a metatheoretic statement about it, hence the "internal".
thanks Madeleine! and Mike!
Mike Shulman said:
it's not clear to me at the moment whether all closed types in System F are bridge-discrete
Hmm, although it's possible this is a consequence of the Reynolds-Abadi logic?
re: 3) I meant system F, so it's good to note your uncertainty. I'm not sure if bridge discreteness follows from internal parametricity as formulated by Reynolds abadi (or anyone else), and regard 3) as key to settling.
understood re: 7) I agree
re 14) I might have seen a reference, I'll try to track that down
re: 16, I'm used to distinguishing eta from function extensionality due to working in Coq so much. I've never seen fun-ext follow from eta. So I was surprised to learn that (x |- f x = g x -> |- f = g) follows from eta in System F, even though it's due to issues with having a type of propositions, etc. Mitchell gives the same argument about this that you did earlier.
for 17) I'm using "internal and external in the sense of 18). But I agree there's another meaning of internal and external meaning that internally you can have a Prop stating that e.g. function extensionality is true which is distinct from it being true externally. I tried to use "definable" instead of "internal" in this bullet list to avoid ambiguity in this specific sense. What I meant by the question was that it seems like people need to build a logic on top of system F (a la plotkin abadi), rather than say add a bunch of 'free theorems' to system F, to capture parametricity. I was trying to confirm you have to do more than just add (infinitely many) equations to the theory of system F to capture internal parametricity.
Ryan Wisnesky said:
I've never seen fun-ext follow from eta. So I was surprised to learn that (x |- f x = g x -> |- f = g) follows from eta in System F,
As I said before, if =
means definitional equality, then that rule is not funext. It is not even a "kind" of funext, unless you want to call eta itself "a kind of funext", because this rule is equivalent to eta.
Ryan Wisnesky said:
for 17) I'm using "internal and external in the sense of 18)
Actually I don't know what you meant by it in (18). What are "conclusions"?
I'm not even sure what you mean by "parametricity" in (17-18). What I mean by "external parametricity" is that there's a translation on syntax transforming every closed type to a relation on its closed terms, defined in the usual way, such that every closed term is related to itself. What I mean by "internal parametricity" is that the syntax contains an operation mapping every type to a relation on itself, defined in the usual way, such that every term is related to itself.
I've not been following this discussion so closely, but it seems like Abadi, Cardelli, and Curien's work on Formal Parametric Polymorphism may be related, as they give a calculus extending System F in which certain parametricity results are provable internally.
Thanks. That looks similar to the Plotkin-Abadi logic we've been discussing; in fact I'm not sure what the difference is. They cite the Plotkin-Abadi paper in the last sentence but it's not clear to me what they're saying about it.
I think I would classify both of them as a way to add "internal parametricity" to System F. (Full internal parametricity requires a dependent type theory.) But I could be misunderstanding something about one or both.
I got the internal/external parametricity distinction (applies in all contexts vs applies in empty context) from here: https://ncatlab.org/nlab/show/parametric+dependent+type+theory . Without a type of propositions, I'm not even sure how system F could "internalize" (mike's sense) parametricity (besides an axiom schema of 'free theorems').
internal vs external in the sense of that ncatlab page seemed relevant, since a ~ CPS a when a is a variable has different properties than c ~ CPS c when c is a closed term
The distinction is correct, but the "thing" that applies in contexts or not is not the conclusions, but the parametricity operator that takes types to relations and terms to witnesses of relations.
Also that nLab page is only about forms of parametricity that are inside the theory:
Parametric dependent type theory is dependent type theory with an explicit notion of parametricity inside of the theory itself
In particular, as it says, it uses "external parametricity" for "explicit external parametricity", which is different from the meta-theoretic external parametricity of Reynolds:
In the rest of this article, we shall follow the terminology of the Narya documentation and use external parametricity for explicit external parametricity. To disambiguate, we shall use meta-theoretic parametricity for the traditional meta-theoretic notion of external parametricity.
Basically all constructive type theories satisfy meta-theoretic external parametricity. But I don't know what "meta-theoretic internal parametricity" would even mean.
Explicit parametricity is indeed harder to make sense of in a non-dependent type theory, but I thought that's what the Plotkin-Abadi and Abadi-Cardelli-Curien logics were trying to do.
I figured "meta-theoretic internal parametricity" meant a parametricity result that also applies to open terms. at least, that's how I used internal/external in the list of items. if that's not a germane distinction for system F, I'll need to re-think the list
If you can point to a paper that does something you would describe as "meta-theoretic internal parametricity", I'd be interested. Otherwise, let's not use that phrase.
Note that ordinary meta-theoretic external parametricity does do something with open terms, as it essentially must in order to give a proof by induction over syntax in a theory with variable binding. Namely, it shows that open terms map related values for their free variables to related outputs, just like abstracted functions.
In my ignorance I'd point at that automated free theorem generator website from a week ago as something that distinguishes closed vs open terms in a parametricity result : it could generate a free theorem for "forall a, forall x, (a->x)->x", but not for "forall x, (a->x)->x" with a left a type variable. could just be a limitation of the tooling however, or a meaningless distinction (which I suppose it must be)
to make progress, I need to figure out what to replace "internal" and "external" with in each item of the list... so that's what I'll be doing next
I didn't say there is no distinction.
fair enough, then in that case the question is, do the distinctions (exclusively) explain any of the phenomena on that list, like I erroneously thought they did, and if they don't, what does... so that's what I'll be thinking through, item by item
But if you apply meta-theoretic external parametricity to an open type, you get an open type that depends on relations corresponding to the free variables. Which is basically the same as if you abstracted over the free variables with forall, applied the "closed term" translation, and then peeled off the corresponding abstractions. So in that sense, the "open terms" translation that's part of external parametricity carries no new information, so it makes sense that the free theorem generator doesn't deal with it. I was just making the point that in order for the induction to go through, the open terms have to be dealt with at some point.
side note: I don't always get indications that you're typing, mike. must be a weird intermittent glitch. I didn't mean to interrupt
No worries, I don't believe in typing notifications anyway.
I don't know if you're as wrong as you seem to think. Most of the places on that list where you distinguished external and internal parametricity seemed correct to me with the meaning of "internal parametricity" that I'm most familiar with, namely explicit internal parametricity in a dependent type theory.
I think the main thing that I don't understand yet is how the Plotkin-Abadi and Abadi-Cardelli-Curien theories are related to each other and to explicitly internally parametric dependent type theory. In particular, to what extent does my intuition for the latter carry over to them.
I think a good answer to this question should resolve most of the open issues on your list.
that's good to know - and I use Coq a lot more than system F - but I am also fixated on answering these for system F to get at "haskell" folklore for blogging reasons. that being said, I'm thinking of starting with a blog post that just compares the folklore that "the term model of STLC is sound/complete for beta/eta" with folklore that "equational specifications (lists, trees, etc) are studied by their inductive theories", because I think the subtleties of doctrine involved here are often under-stated even in textbooks that use both frameworks (such as Mitchell's)
That does also seem worthwhile!
Mike Shulman said:
Basically all constructive type theories satisfy meta-theoretic external parametricity. But I don't know what "meta-theoretic internal parametricity" would even mean.
constructive type theories can have parametricity-breaking primitives
Josselin Poiret said:
constructive type theories can have parametricity-breaking primitives
What's an example of a dependent type theory with a primitive that breaks Reynolds external parametricity?
onlookers will start thinking i'm a one trick pony but typecase is enough
you don't even need internal injectivity of type constructors
i'd love to go back to the original question though, as there's definitely a flavor of getting first order information back out of higher order in SQC: an example is being able to derive ((x = 0) → ⊥) → x invertible
morally a proof of (x = 0) → ⊥
has to go through some proof that (0 = 1)
, but in that case you do know that 1 = x*i
in the current stage
Hmm, interesting. I'm used to thinking of constructivity as the condition ensuring that a theory has a good initial algebra semantics with a gluing construction, which generally implies parametricity as well as canonicity and (with some extra work) normalization. Typecase doesn't really fit well into my mental models. How do you prove canonicity and normalization for a theory with typecase?
And can you tell me again what SQC is?
Mike Shulman said:
Hmm, interesting. I'm used to thinking of constructivity as the condition ensuring that a theory has a good initial algebra semantics with a gluing construction, which generally implies parametricity as well as canonicity and (with some extra work) normalization. Typecase doesn't really fit well into my mental models. How do you prove canonicity and normalization for a theory with typecase?
When you're doing a normalization model for a type theory, you have 2 choices for the interpretation of the universe (and that of the type judgments): positive or negative. The negative version is what you have in mind: a record of abstract relations that verify the minimal interface wrt. neutrals and normal forms. The positive version instead asserts that you already know all types, here are all the codes, and when you need the relation on terms you have a decoding function.
so the negative model lets you prove parametricity results because you can feed it external relations, but the positive model supports typecase
Interesting. So is typecase the "only" constructive alternative to parametricity then? Can you cite some references that prove canonicity/normalization with typecase?
Mike Shulman said:
So is typecase the "only" constructive alternative to parametricity then?
I don't think there's a way to formalize this sentence, but intuitively I don't know of any other way to formalize types: it's either of an inductive type of codes or a negative record
Mike Shulman said:
Can you cite some references that prove canonicity/normalization with typecase?
not that i know of (but i haven't looked into it too hard) but it seems pretty straightforward to add to any formalization that uses the positive interpretation
Can you cite a reference that uses the positive interpretation then?
Josselin Poiret said:
I don't know of any other way to formalize types: it's either of an inductive type of codes or a negative record
It's interesting that there are multiple ways to construct a universe semantically. That isn't the case for any other type constructors that I know of, because they all have a universal property and hence are uniquely determined up to isomorphism. I guess these two approaches correspond basically to choosing a "handedness" of universal property to give to the universe semantically. And if you try to incarnate those universal properties syntactically, then on the one hand you get typecase, and I guess on the other hand you get... univalence?
Mike Shulman said:
Can you cite a reference that uses the positive interpretation then?
All formalizations of logical relation arguments for dependent type theory that I know use it: LogRel-Coq is an example ofc (or LogRel-MLTT if Agda is more your cup of tea)
Mike Shulman said:
and I guess on the other hand you get... univalence?
isn't parametricity finer than univalence already?
Josselin Poiret said:
isn't parametricity finer than univalence already?
What do you mean by "finer"? Neither implies the other, certainly.
Internal parametricity is certainly inspired by a negative view of the universe, but it isn't a universal property. Univalence is basically a universal property, it says that the universe is a classifying space.
Mike Shulman said:
What do you mean by "finer"?
I didn't see that you were talking about internalizing it, sorry.
Josselin Poiret said:
All formalizations of logical relation arguments for dependent type theory that I know use it: LogRel-Coq is an example ofc (or LogRel-MLTT if Agda is more your cup of tea)
Umm... hang on. Maybe I'm misreading that code, but it looks to me like just the usual inductive definition of logical relations over types. That's different from interpreting the universe as an inductive type in the model.
Maybe I don't know the right words to say syntactically to make this point. Categorically, the way these arguments work is that you have a syntactic category which is initial among categories with some structure. You consider some canonical map out of it, like the global sections functor if you're proving canonicity, and then you take the comma category over that functor to make a "glued" category living over the syntactic category, whose objects are "types equipped with a logical relation" or something. You prove that the glued category has the same structure as the syntactic category, and then you observe that since the syntactic category is initial, there's a section of the projection down to it from the glued category, where the section assigns to each type its logical relation.
It looks to me like what you pointed to is talking about the definition of the section. This is always inductive over types (i.e. objects of the syntactic category) because the syntactic category is always initial, never terminal. But I thought we were talking about defining the "universe object" in the glued category, whether it has a positive or a negative universal property as an object of that category.
36 messages were moved from this topic to #learning: questions > universal properties for positive types by Mike Shulman.
so in that Agda code (and also the Rocq one) there's a bit of indirection, but if you look at the reducibility predicate at the universe, it uses the type reducibility predicate of the lower level (the definition here is quantified over a so-called LogRelKit
of lower levels), which is itself obtained by the definition I linked to before
also, this is not the definition of the section: the section is usually called the "fundamental theorem" and is in fact defined in Fundamental
i'm a bit more used to the categorical gluing argument à la STC for dependent type theories, and in that formalism you're basically considering two different definitions for the dependent presheaf over where is what Jon calls a figure shape
(and where is the presheaf over the syntactic category of contexts of syntactic types)
you can do the same for of course
wrt. SQC, it's the axiom that internally to the zariski topos, the canonical map is invertible for a finitely presented -algebra
Ah, SQC = Synthetic Quasi-Coherence -- I know it when it's spelled out. (-:
Josselin Poiret said:
so in that Agda code (and also the Rocq one) there's a bit of indirection, but if you look at the reducibility predicate at the universe, it uses the type reducibility predicate of the lower level (the definition here is quantified over a so-called
LogRelKit
of lower levels), which is itself obtained by the definition I linked to before
Hmm, isn't _⊩¹U the reducibility predicate on the universe? I thought _⊩¹U_∷U/_
would be the proof that all terms in the universe are reducible. Am I reading that code wrong?
What is the minimal background or summary needed to understand this conversation? I want to understand if parametric functions have free theorems attached or not. I tried reading articles of John Reynolds and Philip Wadler, but I was not able to follow them all the way. Now it seems they were wrong?
I can see that a term of type does not denote a natural transformation because the type does not denote a functor. That about sums up what I understood from scrolling through this conversation. I want to understand more but I am dazzled by the expanse of techniques deployed.
If anyone is writing an explanation of this issue, I can be a good representative of general audience and help make it accessible!
the place I'm stuck is finding a complete proof that Reynolds parametricity for system f does or does not imply c ~ CPS c for all closed types c.
Perhaps try asking somewhere like cs.stackexchange.com?
Ignat Insarov said:
Now it seems they were wrong?
I don't think they were wrong. I think our conclusion is more that some people (particularly in the Haskell community) have interpreted their results to say more than they actually do.
I might be one of those people, and I do want to straighten my ways.
Hopefully the blog post(s) will be readable and clarify the situation!
Mike Shulman said:
Hmm, isn't _⊩¹U the reducibility predicate on the universe? I thought
_⊩¹U_∷U/_
would be the proof that all terms in the universe are reducible. Am I reading that code wrong?
no, you're reading it right! when i say the reducibility predicate at the universe, I mean the predicate for terms of type the universe (i.e. each realized type decodes to a reducibility predicate for its terms).
(i realized i had not sent my reply earlier today)
so for a term t : U
to be realized, you need Γ ⊩ t
which refers to type realizability at the lower level, which is itself inductive
But then this is not actually an example of "two different ways to interpret the universe". The definition of _⊩¹U
is the relevant one, and that's what gives the parametricity interpretation. I thought you were saying that _⊩¹U
could also be defined inductively, and that's what I was asking for an example of.
how does this sound for stack overflow? anything I should add or remove? "I am trying to find a proof (or dis-proof) that a Reynolds parametric model of system F is such that for every closed type c, the type c is bijective with the type forall x, (c->x)->x (known as the type of continuations for c). Hyland, Robinson, and Rosolini, in the conclusion of "Algebraic Types in PER Models" (https://www.dpmms.cam.ac.uk/~jmeh1/Research/Pub81-90/hrr90.pdf), give an example c for which this isomorphism fails: (forall x, x->x) -> (forall x, x->x) and conclude "parametricity fails in the system F term model". However, Bartosz Milewski gives a "free theorems" argument (which I've verified in Coq) that this isomorphism must hold (https://bartoszmilewski.com/2015/09/01/the-yoneda-lemma/). So myself and other applied category theorists would like community input to settle these two questions: in system F, does Reynolds parametricity imply every closed type is bijective with its type of continuations? And is the system F term model Reynolds parametric"?
Maybe by "non-proof" you mean "disproof"? It's very easy to find non-proofs, i.e. strings of symbols that aren't proofs.
Mike Shulman said:
But then this is not actually an example of "two different ways to interpret the universe". The definition of
_⊩¹U
is the relevant one, and that's what gives the parametricity interpretation
How does the realizability of the universe give you the parametricity interpretation? It's rather what realizers of terms at type U
that you can feed to polymorphic functions that matter, no?
I don't remember if it's been said before, but wrt. the Q example of HRR, if you suppose that all inhabitants of are already parametric, then in the model
will be equal (in the model) to
which is of the required form
of course it's not a βη-equivalence, but extensionally, if you only probe them by definable functions, they are equal
it's something quite similar to Escardó's seemingly impossible functional programs, which work only when you feed them definable predicates
Ryan Wisnesky said:
Bartosz Milewski gives a "free theorems" argument (which I've verified in Coq) that this isomorphism must hold
can you be more explicit about what exactly you've proven? just that web page isn't enough for me to infer it
Josselin Poiret said:
onlookers will start thinking i'm a one trick pony but typecase is enough
Do you have any references / papers that talk about dependent type theory with typecase?
Madeleine Birchfield said:
Do you have any references / papers that talk about dependent type theory with typecase?
"The next 700 syntactical models of type theory" by Boulier et al. mentions typecase
Josselin Poiret said:
How does the realizability of the universe give you the parametricity interpretation? It's rather what realizers of terms at type
U
that you can feed to polymorphic functions that matter, no?
The fact that the parametricity translations of Type
and Π
are
Typeᵖ X Y = X → Y → Type
Πᴾ X Y f₀ f₁ = (x₀ x₁ : X) (x₂ : Xᵖ x₀ x₁) → Yᵖ (f₀ x₀) (f₁ x₁)
tells you that, for instance, the parametricity translation of (X : Type) → X → X
is
((X : Type) → X → X)ᵖ F G =
(X₀ X₁ : Type) (X₂ : X₀ → X₁ → Type) (x₀ : X₀) (x₁ : X₁) → X₂ (F x₀) (G x₁)
Therefore, for any (closed) F : (X : Type) → X → X
, its translation Fᵖ
tells you that F
must preserve all relations, from which you get its free theorem.
Where Typeᵖ X Y = X → Y → Type
is, I believe, what _⊩¹U
says (maybe in the unary case).
Ryan Wisnesky said:
how does this sound for stack overflow? anything I should add or remove? "I am trying to find a proof (or dis-proof) that a Reynolds parametric model of system F is such that
Is there a precise definition of the phrase "Reynolds parametric model of system F"?
If so, maybe link to it. If not, maybe clarify that there isn't (yet) one, but that you mean some class of models including PER models that satisfy parametricity "internally" in some sense.
Also I think I wouldn't cite Milewski, since we know what's wrong with his argument. Instead I would say that HRR show that even for their own , the isomorphism does hold in their PER model. So the question is whether there are any "even worse" closed types for which the isomorphism even fails in internally parametric / PER models, or whether one can show that it works there for all closed types.
remind me what went wrong with Milewski's argument? His argument had convinced me that c ~ CPS c for closed c in a parametric model (or at least a model with the 'free theorem' for the Reader and Id functors), from which I concluded the term model is not (fully) parametric. Am I mis-interpreting his argument or the Coq that formalized his argument?
I think I'd use the Adadi-Plotkin paper to define Reynolds parametricity, but am open to suggestions
The isomorphism c ~ CPS c depends on knowing that all transformations are natural, which in turn requires c to be bridge-discrete to prove it from parametricity (even internal parametricity). IIRC the Coq formalization just assumed that all transformations are natural.
So the real question is whether "internal parametricity" of some kind for system F implies that all types are bridge-discrete.
Evan proved that all types in the first universe of internally parametric predicative dependent type theory are bridge-discrete, but that doesn't consider the impredicative .
both the coq code and the milewski post assume that any function of type "forall a, F a -> G a", where F and G are internal functors (in this case F=Reader and G=Id), is a natural transformation, this is true. In milewski's case I think he tries to establish this from the Yoneda lemma, and I just assumed it as a "free theorem" in the sense of wadler (and therefore implied by parametricity alone to my way of thinking). But both arguments seem to bypass bridge discreteness (although maybe they shouldn't), which is confusing me. (for sanity I'm going to stick to working in system F and interpreting milewski in system F). image is milewski's "axiom"
Screenshot 2025-07-11 at 5.09.10 PM.png
Yoneda only applies when you already have a natural transformation.
He states it using forall
but that's because he's previously asserted that all transformations are natural.
Without even attempting a proof here:
Haskell’s parametric polymorphism has an unexpected consequence: any polymorphic function of the type
alpha :: F a -> G a
whereF
andG
are functors, automatically satisfies the naturality condition.... The reason why the naturality condition is automatic in Haskell has to do with “theorems for free.”... In the case of functions that transform functors, free theorems are the naturality conditions.
and here
If you accept the premise that an appropriate relation can be defined for any functor, then you can derive a free theorem for all polymorphic functions of the type
r :: forall a. f a -> g a
wheref
andg
are functors. This type of function is known as a natural transformation between the two functors, and the free theoremfmap h . r == r . fmap h
is the naturality condition.
But I think we worked out before that this just isn't true. There is a free theorem for the type , for any functors and , but it isn't by definition naturality, and to extract naturality from it you need the identity extension lemma for and .
And the identity extension lemma for requires to be bridge-discrete.
ok. I think that is a good summary of the failure of folklore: naturality does not follow from parametricity in general , so "theorems for free" is not the same as "Reynolds parametricity". Indeed, Wadler might even be conflating these concepts in his "free theorems" paper !?
anyway, I think the blog post will probably need to give the free theorem and show how it isn't the same as naturality, and walk through how bridge discreteness implies identity extension implies naturality, but i think I'm unblocked on writing even without the stack overflow post now: naturality simply does not follow from parametricity. Which is actually a bit surprising because I've seen it claimed at a high level that parametricity generalizes naturality from functions to relations
the plotkin abadi identity extension lemma refers to all types, not just bridge discrete ones (but has no proof). does this mean their logic is actually capturing a notion of parametricity that might always imply naturality? (side note: I saw a remark that identity extension is what separates a parametric model from one that is simply defined using a logical relation, and wonder if that distinction has been showing up here: a parametric model is one where identity extension holds for all types, whereas a logical relation defined model only has that property for bridge discrete types, or something along those lines). Image is of remark from https://par.nsf.gov/servlets/purl/10338496
Screenshot 2025-07-11 at 6.26.58 PM.png
Maybe!
I think I would just call them different forms of parametricity, though. "Internal parametricity" is pretty well-established as a name for a class of dependent type theories, and we decided that those don't satisfy universal identity extension or bridge-discreteness.
Maybe this is "strong parametricity" or "impredicative parametricity" or something.
ok, great; then to conclude, in that case I'd say the HRR conclusion comment is noticing that the term model fails to be "strong parametric", even though it does satisfy weaker forms of parametricity (such as polymorphic identity having one inhabitant), giving q ~ cont q as the witness, and this thread quantifies the difference between the two situations using the "bridge discreteness" of a type
That sounds good, but I'm not ready to conclude until I see a proof of the identity extension lemma.
a proof of the identity extension lemma for which models/logics are you referring to?
At https://cs.stackexchange.com/a/136373/185120 András Kovács claimed that "For System F, identity extension can be proven for types-in-contexts", but wasn't able to produce a reference when I asked.
the plot thickens; identity extension for system F would in my mind contradict HRR's claim that q is not iso to cont q in the term model. my current thinking is no such proof should exist
there's a proof of (qualified) identity extension as prop 9 in wadler's paper https://homepages.inf.ed.ac.uk/wadler/papers/gr2/gr2-tcs.pdf but it's in natural deduction style and so taking me a while to understand. This post by Neel K is ambiguous about whether the F term model satisfies identity extension depending on how the word "the model" is interpreted: https://semantic-domain.blogspot.com/2020/12/church-encodings-are-inductive-types.html
Ryan Wisnesky said:
the plot thickens; identity extension for system F would in my mind contradict HRR's claim that q is not iso to cont q in the term model. my current thinking is no such proof should exist
Could it be a definitional vs contextual thing? E.g. maybe the form of IEL that holds only shows that every element of CPS q behaves like an element of q when applied to all possible closed term inputs, and the exotic HRR term does that?
I think Josselin made a similar remark yesterday? I suppose I'll write to Neel K as a next step.
Seems sensible; I think he's usually pretty careful.
Here's what Neel said: "There is no incompatibility between the parametricity of the syntactic model and Hyland's note. Hyland considers the naive PER model, in which every type is interpreted solely as a partial equivalence relation (PER) which is well-known to be weak to prove parametricity results. To prove parametricity results, you need a relationally parametric model, in which every type is interpreted both as a PER, and a relation between PERs.
The place where the parametric model over PERs is documented is in Bainbridge, Freyd, Scedrov and Scott's paper "Functorial Polymorphism". The first half of their paper is a (failed) attempt to interpret parametricity as dinaturality, after which they go ahead and build a syntactic parametric PER model, where types are PERs/relations over Godel codes. Among other results, they prove that their relational model satisfies the identity extension property.
Their proof only relies on the Godel codes forming a partial combinatory algebra, and so you can plug in any PCA -- and lambda terms obviously form one. Recall that a PCA is basically an axiomatization of the algebra of the SKI combinators, and so you can make the lambda calculus into a PCA with the usual definitions S = λf.λg.λx.f x (g x) and K = λx.λy.x.
Once you do this, then it's immediate that the parametric term model satisfies identity extension."
Interesting. So he seems to be saying that in order to get IEL, you can't actually look at the term model in the usual sense, but you have to use a model in relations that builds in some strong parametricity. That makes sense with my intuition.
Did you ask him specifically about Kovács' claim that "For System F, identity extension can be proven for types-in-contexts"? That sounds like it's a statement about the ordinary term model rather than a relation model constructed from it.
yeah, I was not expecting him to start talking about a model using untyped lambda terms in reference to the term model. Here's what I asked: "Myself and some other type theorists / category theorists were hoping you might be able to help settle an apparent open folklore question concerning system F. We’re writing specifically because of your illuminating blog post at https://semantic-domain.blogspot.com/2020/12/church-encodings-are-inductive-types.html .
The conclusion of ‘Algebraic types and PER models' by Hyland et al (https://www.dpmms.cam.ac.uk/~jmeh1/Research/Pub81-90/hrr90.pdf) exhibits a failure of “parametricity” in the system F term model by constructing a closed type c for which c is not bijective with forall x, (c -> x) -> x (the type of continuations for c) in the term model.
At the same time, it seems to be folklore that the system F term model is parametric, with for example Andy Kovacs stating that identity extension should hold in the term model (https://cs.stackexchange.com/questions/136359/rigorous-proof-that-parametric-polymorphism-implies-naturality-using-parametrici/136373#136373). There are many other such claims in the literature, yet Mike Schulman and I can’t find any proofs. In fact, I’m starting to believe the term model does not satisfy identity extension, which would explain Hyland et al’s claim (I think).
So, do you know of a proof or dis-proof that the system F term model satisfies identity extension (however suitably formulated for the term model)?"
Ok, he does seem to be saying that the term model doesn't satisfy identity extension, but it's not completely clear. Maybe you could ask for a clarification, emphasizing that by "term model" you mean the initial model build directly from the syntax of system F?
I asked neel the follow-up: "it seems like here by term model you are talking about a model of system F built from untyped lambda terms, passing through their PCA. But what Mike and I meant by the term model of system F was the initial model built directly from the syntax of system F. I’m not even sure how to state identity extension for the term model in the Mike/Ryan sense, but I’m wondering if you can comment on identity extension in the typed term model of system F, rather than the untyped PCA model. Thanks again!" and he replied with a detailed answer, but again not what I was expecting. My understanding of his response is that the untyped PER model somehow "is also" the term model.
Screenshot 2025-07-14 at 7.53.38 AM.png
That does seem to be what he's implying, but that's clearly false because the (initial) term model is not defined mutually recursively with any relational interpretation. Why don't you add me to the email thread and we can all continue there instead of playing telephone? (-:
Will do, although here's a final thought before doing so: to obtain a set-theoretic model of system F terms, the machinery of logical relations might already be required, for example, to inductively define terms that strongly normalize. So maybe there is a sense in which the system F term model does have to be constructed alongside its relational interpretation.
Every type theory has an initial model built out of syntax. It's not a "set-theoretic" model in the sense of interpreting each type as a set, but it always exists.
In particular, it doesn't depend on any sort of normalization.
5 messages were moved from this topic to #learning: questions > What is a term? by Mike Shulman.
Mike Shulman said:
Where
Typeᵖ X Y = X → Y → Type
is, I believe, what_⊩¹U
says (maybe in the unary case).
What I'm saying is precisely that it does not, that would be the negative interpretation of the universe
you have two choices, either _⊩¹U
consists of metatheoretical relations with some conditions on them that makes them behave as realizability relations, or it is just a universe of codes that then decode to the expected relations. The difference between the two is that the former contain undefinable relations while the second, by construction, only contains definable relations
I guess I just can't make heads or tails of that Agda. Can you write out the definition of _⊩¹U
in words? I agree it doesn't look like the negative interpretation, but it doesn't look like a positive inductive definition either.
I'm revisiting an example from tannen coquand. consider the type T := (forall x, x) -> (forall x, x) -> (forall x, x). Then there are two distinct terms in this type T, essentially, "project first component" and "project second component". But in an extensional model where forall x, x is empty, this type T should have only one inhabitant. In tannen coquand they conclude the term model is not extensional. So my question: could the HRR result be similarly (better?) understood as a failure of extensionality than parametricity in the term model?
What does "extensional" mean?
I've attached tannen coquand's definition, which I understand to be a semantic criteria similar to (forall x, f x = g x) -> f = g for both function types and forall types.
Screenshot 2025-07-15 at 5.02.05 PM.png
Ok, they mean equality of functions is detected by applying them to global elements. I would call that being well-pointed.
And of course no one should expect the term model to be well-pointed.
Ryan Wisnesky said:
could the HRR result be similarly (better?) understood as a failure of [well-pointedness] than parametricity in the term model?
Well, can you show that the exotic term would be equal to some standard one in any well-pointed model?
the HRR argument for PER models seems to apply to well pointed ones also, but I figured someone here might already know or have a proof
I want to record in this thread something that I didn't realize explicitly at first, namely that strong parametricity (= external parametricity plus identity extension) implies internal parametricity.
By external parametricity I mean firstly operations on closed terms such as
but to define these recursively on syntax we have to extend them to open terms by also "degenerating the context", e.g.
External parametricity satisfies identity extension if , and similarly in the dependent case.
By internal parametricity I mean operations on possibly-open terms that don't degenerate the context, such as
Now if you already have external parametricity, to get internal parametricity it suffices to add these operations on variables, since then you can obtain (for instance) the internal as the external . (This is how "observational" parametricity, as in Narya, computes with its internal parametricity operator.)
But identity extension also suffices, since you can also use instead of .
Mike Shulman said:
Now if you already have external parametricity, to get external parametricity it suffices to add these operations on variables,
Don't you mean internal parametricity in the second clause?
Yes, thanks.
Mike Shulman said:
I guess I just can't make heads or tails of that Agda. Can you write out the definition of
_⊩¹U
in words?
So the main definition in there is _⊩¹_
, which defines the realizability predicate for types (what Jon calls ).
Note that the ¹
is slightly misleading here, it should be understood as ⁺¹
instead, as it builds the predicate for types at level higher than the given rec
in the module telescope. So when l = 0
and rec
equals λ ()
, it actually builds the realizability predicate for small types.
What it says is that for a type A
to be realized, it should either verify:
ℕ
Empty
Unit
Π
or Σ
of a type + family over it, they're both realizable after an arbitrary weakening1
and it's literally the universe (here there's a trick, since there is no large elimination, it's impossible for a term that reduces to U
to not be U
itself already)Note that this information does not contain an arbitrary realizability relation for terms at that type, it's entirely decoded from the above. This is in contrast with semantic approaches I know of in the literature, where you additionally ask for a relation on terms that reflects neutrals and reifies to normals, and you use that relation when realizing inhabitants of this semantic type.
_⊩¹_
, the positive interpretation, is thus a subtype of the negative version in the literature. One advantage is that the realizability relation is entirely determined by the syntax.