coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Lasse Blaauwbroek <lasse AT blaauwbroek.eu>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Proving transitiviy of simple type system
- Date: Tue, 3 Oct 2023 00:15:40 +0200
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=lasse AT blaauwbroek.eu; spf=Pass smtp.mailfrom=lasse AT blaauwbroek.eu; spf=None smtp.helo=postmaster AT mail.blaauwbroek.eu
- Ironport-data: A9a23:jZeCwqsfL0H8plLh4GWoRJnFEefnVOlYMUV32f8akzHdYApBsoF/q tZmKWzXbKnZNmX9ctsiPYSy8EJSvpSEnd9nSVNoqSE8QyhGgMeUXt7xwmXYb3rDdJWbJK5Ex 5xDMYeYdJhcolv0/ErF3m3J9CEkvU2wbuOgTrSCYEidfCc8IA85kxVvhuUltYBhhNm9Emult Mj7yyHlEAbNNwVcbCRMsMpvlDs15K6p4WtA5ARkDRx2lAa2e0c9XMp3yZ6ZdCOQrrl8RoaSW +vFxbelyWLVlz9F5gSNz94X2mVTKlLjFVDmZkh+A8BOsTAezsAG6ZvXAdJHAathZ5plqPgqo DlFncTYpQ7EpcQgksxFO/VTO3kW0aGrZNYriJVw2CCe5xSuTpfi/xlhJG4ZPKED9sBQO2dt9 9oWCy8NLTOY3f3jldpXSsE07igiBMziPYdZsHVpxCzGB+whTJOFTriiCd1whWdtwJoSW6yEP 4xGMFKDbzyYC/FLElMeE4kztO2sj3DibDdCr1+W46cqi4TW5FUrgeC9bIuKJbRmQ+13uXajl F7W21/hDzchd4aU1Dra92Cz07qncSTTHdh6+KeD3vVtmRiYwnEZIAYHUEOy5/i/kE+3HdxFQ 3H44QIrpKk2skavR9DgQBeip3OH+BMBMzZNL9AHBMi24vK8y26k6qIsF1atsfR25JFkdi9gz VKTgdLiCBpmtbDfGzrX9a6ZoXn2cWIZJHMLL31MBwYUwcjRkKdqhDL2T/FnDPGUiP/xEmrO2 DyklnU1qIgSqs8p7J+F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r: 651b4115_ykPJEh3hJCiDxVMqIrzqVEVVIctjDdaqZGRdmP7FjtBfanW +i9erz1MJllp4GdvnU60L9pmSIFNb31f4kY2jaA==
Although Jean-Marie's and Jason's generalizations both work here, I believe that the crucial point is still that this subtyping relation is trivial. As far as I know, for most sufficiently "interesting" subtyping relations, transitivity and reflexivity are not provable without axiomatizing them. That is, you have to add reflexivity and transitivity constructors (unless you modify all other constructors such that transitivity is "built-in", but that amounts to the same thing). For example, as soon as you have type variables you will not be able to prove "\alpha < \alpha" without the axiom.
I'd be curious to know what kind of type-system you have in mind where this is not needed?
On 02-10-2023 23:43, Jean-Marie Madiot wrote:
Hello Frédéric,
One standard "Coq trick" that you may already know is to generalize the statement before performing the induction, typically by doing something like "revert t3 HSubR; induction HSubL" or "revert t1 HSubL; induction HSubR" in your example.
However typeSub is contravariant in one of its argument, which makes things more interesting: only generalizing for all "HSubL" or for all "HSubR" won't be enough, you need to be able to switch sides.
Suppose that you have a coarser (hence non trivial) subtyping relation such as
Inductive typeSub : type -> type -> Prop :=
| SubTUnit : typeSub TUnit TUnit
| SubTFunUnit : forall ti to, typeSub (TFun ti to) TUnit
| SubTFun : forall ti1 to1 ti2 to2, typeSub ti2 ti1 -> typeSub to1 to2 -> typeSub (TFun ti1 to1) (TFun ti2 to2).
Infix "<" := typeSub.
Then you can generalize on both sides in this way:
Lemma trans_aux t1 t2 : t1 < t2 -> (forall x, x < t1 -> x < t2) /\ (forall x, t2 < x -> t1 < x).
Proof.
intros HSub; induction HSub; split; intros x Hx; inversion Hx; subst; constructor; firstorder.
Qed.
Lemma trans: forall t1 t2 t3, t1 < t2 -> t2 < t3 -> t1 < t3.
Proof.
intros t1 t2 t3 HSubL.
apply trans_aux, HSubL.
Qed.
Regards,
Jean-Marie
Le 02/10/2023 à 19:53, Frederic Fort a écrit :
Hello,
I am trying to prove the some facts about the type system of a simple Lambda calculus. However, I struggle to prove the transitivity of the subtype relation.
I have seen in papers that certain people simply "axiomatize" properties like transitivity and reflexivity by defining specific rules for these properties.
However, I find this inelegant as this makes proofs in other places more "cluttered" due to the additional constructors.
I have a few proofs that work fine. For transitivity however, I am stuck.
I have tried all kinds of (dependent) induction approaches, but I am generally stuck either because Coq requires me to prove that the unit type is a subtype of a function type or because the induction hypothesis doesn't take into account that subtyping of function input types is in the "opposite direction".
I suppose that there is some "Coq trick" that I am unfamiliar with (maybe I have to define a custom induction scheme ?).
Or maybe it is actually impossible to prove transitivity like that.
If somebody could show me what I am missing, I'd be grateful.
Yours sincerely,
Frédéric Fort
Here are my definitions:
Inductive expr :=
| Unt
| Var (n : nat)
| Lam (v : nat) (e : expr)
| App (f : expr) (arg : expr)
.
Inductive type :=
| TUnit
| TFun (tin tout : type)
.
Inductive typeSub : type -> type -> Prop :=
| SubTUnit : typeSub TUnit TUnit
| SubTFun : forall ti1 to1 ti2 to2, typeSub ti2 ti1 -> typeSub to1 to2 -> typeSub (TFun ti1 to1) (TFun ti2 to2)
.
Lemma refl:
forall t, typeSub t t.
Proof.
intros.
induction t; constructor; auto.
Qed.
Lemma sub_is_eq:
forall t1 t2, typeSub t1 t2 -> t1 = t2.
Proof.
intros.
induction H.
- reflexivity.
- rewrite IHtypeSub1. rewrite IHtypeSub2. reflexivity.
Qed.
Lemma trans:
forall t1 t2 t3,
typeSub t1 t2 -> typeSub t2 t3 -> typeSub t1 t3.
Proof.
intros t1 t2 t3 HSubL HSubR.
Admitted.
- [Coq-Club] Proving transitiviy of simple type system, Frederic Fort, 10/02/2023
- Re: [Coq-Club] Proving transitiviy of simple type system, Jason Hu, 10/02/2023
- Re: [Coq-Club] Proving transitiviy of simple type system, Lasse Blaauwbroek, 10/02/2023
- Re: [Coq-Club] Proving transitiviy of simple type system, Frederic Fort, 10/02/2023
- Re: [Coq-Club] Proving transitiviy of simple type system, Jason Hu, 10/02/2023
- Re: [Coq-Club] Proving transitiviy of simple type system, Frederic Fort, 10/02/2023
- Re: [Coq-Club] Proving transitiviy of simple type system, Jean-Marie Madiot, 10/02/2023
- Re: [Coq-Club] Proving transitiviy of simple type system, Lasse Blaauwbroek, 10/03/2023
- Re: [Coq-Club] Proving transitiviy of simple type system, Jason Hu, 10/03/2023
- Re: [Coq-Club] Proving transitiviy of simple type system, Lasse Blaauwbroek, 10/03/2023
- Re: [Coq-Club] Proving transitiviy of simple type system, Jason Hu, 10/03/2023
- Re: [Coq-Club] Proving transitiviy of simple type system, Lasse Blaauwbroek, 10/03/2023
- Re: [Coq-Club] Proving transitiviy of simple type system, Thorsten Altenkirch, 10/03/2023
- Re: [Coq-Club] Proving transitiviy of simple type system, Xavier Leroy, 10/03/2023
Archive powered by MHonArc 2.6.19+.