I'm working through Programming Language Foundations in my free time. In the subtyping chapter, I am greeted by the following exercise, where TF P := P \/ ~ P
:
Theorem formal_subtype_concepts_tfh:
TF (exists f : nat -> ty,
(forall i j, i <> j -> f i <> f j) /\
(forall i, f i <: f (S i))).
This is my type system:
Inductive ty : Set :=
Ty_Top : ty
| Ty_Bool : ty
| Ty_Base : string -> ty
| Ty_Arrow : ty -> ty -> ty
| Ty_Unit : ty
| Ty_Prod : ty -> ty -> ty.
where Top
is the type that all types are a subtype of.
I believe this statement is false (the right branch, ~P is provable). My logic for this is that the second condition in the conjunction,
forall i, f i <: f (S i)
states that the output of (f i) is a subtype, or more specific than the output of (f (S i)). This would mean that (f 0) would have to be the most specific type in a series, which should not be possible given just product and arrow types (both of which have an unbounded, finite size).
So, the contradiction should arise from a statement I've already proven:
Theorem no_least_type :
~ (exists S, forall T, S <: T).
The difficulty I'm having is generalizing this concept without a definition
for f
. I want to say that to satisfy the first branch of the conjunction,
f must use either T_Arrow, T_Prod or T_Base as the output of the successor
case of its input. And because there are no such arrow, product, or base types that
satisfy the second branch of the conjunction, the statement must be false. Unfortunately, my attempts at these lemmas quickly blow up beyond what seems reasonable.
I've also attempted to directly specialize no_least_type
with f i
to solve the problem, but applying that to a False
goal obligates me to prove that
forall f i T, (f i <: f (S i)) -> (f i <: T)
which is going in the wrong direction to be provable. This does seem like a promising direction for the proof though, because any induction on either a type or piece of subtyping evidence would quickly blow up, which Pierce seems to avoid in exercises.
Is there any fundamental insight I'm missing here?