coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Gert Smolka <smolka AT ps.uni-saarland.de>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Dependent typing puzzle, constructor injectivity
- Date: Sun, 14 Feb 2021 09:59:30 +0100
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=smolka AT ps.uni-saarland.de; spf=Pass smtp.mailfrom=smolka AT ps.uni-saarland.de; spf=None smtp.helo=postmaster AT triton.rz.uni-saarland.de
- Ironport-phdr: 9a23:YZfKqx8ZHhtaj/9uRHKM819IXTAuvvDOBiVQ1KB31+8cTK2v8tzYMVDF4r011RmVBNSdta4P0rKH+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZLebxhMiTanYL5/Ixq6oRjNusQSnIBvNrs/xhzVr3VSZu9Y33loJVWdnxb94se/4ptu+DlOtvwi6sBNT7z0c7w3QrJEAjsmNXs15NDwuhnYUQSP/HocXX4InRdOHgPI8Qv1Xpb1siv9q+p9xCyXNtD4QLwoRTiv6bpgRRn1gykFKjE56nnahMxsg6xUrx2vuhJxw4DKbo6XN/RwebjQfc8DRWpEQspRVzBNDp26YoASD+QBJ+FYr4zlqlUPsxS+HxWsD/7yxD9NgX/22a463P48GgzBxwwgGtUOsHDXrNrvL6oSSfu1wLPVzTXFbvNawCz955LSfRA7pfGDR7RwftfLxUYyCQzIl1OdopHqMD2JzOoCqXSb7/Z+WuK1jW4qsxx9rDexysswhIfFm58Yxk7Y+Ch93Is4KtK1RFN/bNOnDpZetzyXO5d4TM88Xmxmtzg3xqEIt5OlYiUHypcqyh7ZZveacIaI+gruWPufLDp3nn5ofLOyiwyw/ES61OHxVtG43VJEoyZfj9XBsnMA2wbN5sWHVPdx5Fqt1DaL2g3V9+pKO1o7lbDBJJ4k2rMwloQcsUDEHiLuhEX2lq6Wdlkj+uiu8ejneLTnqoWBN49yiwHyK78uldalDuQiNggBRW6b9vmm2LL+40L1WLRKjvsonanFqJ3WOMoWq6GjDwJR04sv8RSyAy243NkYhXUHKUhKeBODj4jnIVHOJ/X4AO+kg1Splzdrw/PGMaf6D5XVNXjPiqrhfbB860JF0wo818pQ54hQCr4bJvL8R1X9u8HGARMhKQy73/7nCMlh1oMZQW+AHqiZMLrLvVCU4uIvPvKDaZQOuDf9Lvgl/+ThgWU4mV8bZ6mp3IEYZGq2HvR8cA2lZi/nhc5EGmMXtCI/SvbrgRuMS219fXG3Co0x/C1zM4ehCYTKDtS2hbuF3y6TBoYQe2ZHT0uFGG3sfoOIHfsBPnHBavR9myAJAODyA7Qq0guj4Vejl+hXa9HM8yhdjqrNkcBv7reLxwkpsyFyDoGG2miXS2hykiUESm1uhfEtkQlG0l6GlJNArbldHN1X6elOV11iZ4bHifF8CpXpUwvbet6PRBCqT4f/WGxjfpcK29YLJn1FNZCigxTEhXX4H6UUi7uNQoYmtL/a3j3qLs9nz3/A2O8tggt+Tw==
Dear Dominique,
beautiful! Working with a general inversion operator (K_invert)
and exploiting the injectivity of inr and existT yields an elegant
general scheme.
Thanks, Gert
> On 13. Feb 2021, at 22:42, Dominique Larchey-Wendling
> <dominique.larchey-wendling AT loria.fr> wrote:
>
> Dear Gert,
>
> This is mainly what you did, which is implementing
> the inversion function by dependent pattern matching.
> Some short code below,
>
> Best regards,
>
> Dominique
>
> PS: I guess if you do not have nat but an unspecified type
> X with S : X -> X, then you cannot show injectivity of
> the constructors.
>
> -----------------------------
>
> Fact inr_inj {A B} (x y : B) : @inr A B x = inr y -> x = y.
> Proof. inversion 1; trivial. Qed. (* Lazy here *)
>
> Fact DPI_nat :
> forall (p: nat -> Type) n a b, existT p n a = existT p n b -> a = b.
> Proof.
> (* Follows with Coq.Logic.Eqdep_dec.UIP_refl_nat *)
> Admitted.
>
> Inductive K (x: nat) : nat -> Type :=
> | K1: K x (S x)
> | K2: forall y z, K x y -> K y z -> K x z.
>
> Definition K_invert x y (H : K x y) : (( y = S x ) + { z : nat & K x z * K
> z y })%type :=
> match H with
> | K1 _ => inl eq_refl
> | K2 _ y z H1 H2 => inr (existT _ y (H1,H2))
> end.
>
> Fact K2_injective x y z a b a' b':
> K2 x z y a b = K2 x z y a' b' -> (a,b) = (a',b').
> Proof.
> intros H.
> now apply f_equal with (f := K_invert _ _), inr_inj, DPI_nat in H.
> Qed.
>
- [Coq-Club] Dependent typing puzzle, constructor injectivity, Gert Smolka, 02/13/2021
- Re: [Coq-Club] Dependent typing puzzle, constructor injectivity, Gert Smolka, 02/13/2021
- Re: [Coq-Club] Dependent typing puzzle, constructor injectivity, Kenji Maillard, 02/13/2021
- Re: [Coq-Club] Dependent typing puzzle, constructor injectivity, Dominique Larchey-Wendling, 02/13/2021
- Re: [Coq-Club] Dependent typing puzzle, constructor injectivity, Gert Smolka, 02/14/2021
- Re: [Coq-Club] Dependent typing puzzle, constructor injectivity, Dominique Larchey-Wendling, 02/14/2021
- Re: [Coq-Club] Dependent typing puzzle, constructor injectivity, Gert Smolka, 02/14/2021
- Re: [Coq-Club] Dependent typing puzzle, constructor injectivity, Dominique Larchey-Wendling, 02/14/2021
- Re: [Coq-Club] Dependent typing puzzle, constructor injectivity, Gert Smolka, 02/14/2021
- Re: [Coq-Club] Dependent typing puzzle, constructor injectivity, Gert Smolka, 02/14/2021
- Re: [Coq-Club] Dependent typing puzzle, constructor injectivity, Dominique Larchey-Wendling, 02/14/2021
- Re: [Coq-Club] Dependent typing puzzle, constructor injectivity, Gert Smolka, 02/14/2021
- Message not available
- Re: [Coq-Club] Dependent typing puzzle, constructor injectivity, Gert Smolka, 02/14/2021
- Re: [Coq-Club] Dependent typing puzzle, constructor injectivity, Gert Smolka, 02/13/2021
- Re: [Coq-Club] Dependent typing puzzle, constructor injectivity, Jeremy Dawson, 02/14/2021
Archive powered by MHonArc 2.6.19+.