Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Coq Standard Library Requests

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Coq Standard Library Requests


Chronological Thread 
  • From: Beta Ziliani <beta AT mpi-sws.org>
  • To: Coq Club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Coq Standard Library Requests
  • Date: Thu, 23 Aug 2018 11:57:50 -0300
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=beta AT mpi-sws.org; spf=Pass smtp.mailfrom=beta AT mpi-sws.org; spf=None smtp.helo=postmaster AT jupiter.mpi-klsb.mpg.de
  • Ironport-phdr: 9a23:w9/HVxb/mMC6gZu1OKN+yEj/LSx+4OfEezUN459isYplN5qZoMi9bnLW6fgltlLVR4KTs6sC17KJ9fi4EUU7or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRpOOv1BpTSj8Oq3Oyu5pHfeQpFiCa/bL9oMBm6sRjau9ULj4dlNqs/0AbCrGFSe+RRy2NoJFaTkAj568yt4pNt8Dletuw4+cJYXqr0Y6o3TbpDDDQ7KG81/9HktQPCTQSU+HQRVHgdnwdSDAjE6BH6WYrxsjf/u+Fg1iSWIdH6QLYpUjm58axlVAHnhzsGNz4h8WHYlMpwjL5AoBm8oxBz2pPYbJ2JOPZ7eK7WYNEUSndbXstJVSNBDIOyYYUMAeQcI+hXs5LwqEESoRakHwSgGP/jxz1Oi3Tr3aM6yeMhEQTe0QE9Ad0OrG7bp8j2O6cTVeC1zbPHzTPCb/hL3jry85bHcgw7rvyXWLJwacvRxVA0FwLLlVWcs4vlPyma1ukUtWWQ8uluVfq3hmI6pQx8piKjytooh4XThY8Yy0rI+Th5zYotO9G0VEp2bcSnHZZQrS2WKZZ6T8w4T2xopio3zKANt4ShcygQ0psnwgbSa/yZfIiM5RLuTOSRISpghHJkZLKwmQyy/VKlyu3kV8m4yVVKri5ektbXrHwN0gTT6sedRvRg4EitwTeP1wbN5eFYOU04iKTWJpo7zrItkpcfq0fOEy7slEnrjKKabkAk9fKp6+TjbLXmvJicN4pshw7lLKsuhtawDP89MggWXmiX4P+81bP4/UHjR7VKlPI2nrHDsJ/GPcQburK5AwhN34k/7Ba/Fi6q38gcnXkaN11IYwmHjojsO1HWOv/0F/a/g1K2kDdq3f/KJLPhAo+eZkTExZzmZP5W71NWgF44yska7JZJAJkAJujyUwn/roqLIAU+NlmezvruQOd80oIXX2PHVqWULKr6tEeJo/kwOK+LfoBD62W1EOQs+/O71SxxolQaZ6T8mMJPMCnpTMQjGF2QZD/XuvlEFG4LugQkS+mz0w+HST8WfGmpGaUm6WNiUd70PcL4XomoxYe58mKjBJQPPTJDElHJCmjzMYKeVKVUMX/AEopaijUBEIOZZcoh2BWp7lKoyad/L/bZ4GsdrZOm19xu7avWjR50+TEmV8k=

I'm not a coq-dev, but I guess the most reasonably thing to do is to add a PR in github.

On Thu, Aug 23, 2018 at 11:48 AM, Larry Darryl Lee <Larry.Lee AT nolijconsulting.com> wrote:
Hi,

I recently worked on a small project and noticed that the List library
within the Coq Standard library is missing two obvious proofs.

First, the List library defines a proof `Forall_impl` that has an
obvious analog for the `Exists` predicate.

Second, the List library defines a proof `Forall_inv` that applies to
the head of a list, but lacks the obvious analogue for the tail of a
list.

I'd like to propose adding two proofs to the Standard List library. The
first, is a proof `Exists_impl` which fills the gap left by
`Forall_impl`:

    (**
      Accepts two predicates, [P] and [Q], and a
      list, [xs], and proves that, if [P -> Q],
      and there exists an element in [xs] for which
      [P] is true, then there exists an element in
      [xs] for which [Q] is true.
    *)
    Definition Exists_impl
      :  forall (A : Type) (P Q : A -> Prop),
         (forall x : A, P x -> Q x) ->
         forall xs : list A,
           Exists P xs ->
           Exists Q xs
      := fun _ P Q H xs H0
           => let H1
                :  exists x, In x xs /\ P x
                := proj1 (Exists_exists P xs) H0 in
              let H2
                :  exists x, In x xs /\ Q x
                := ex_ind
                     (fun x H2
                       => ex_intro
                            (fun x => In x xs /\ Q x)
                            x
                            (conj
                              (proj1 H2)
                              (H x (proj2 H2))))
                     H1 in
              (proj2 (Exists_exists Q xs)) H2.

    Arguments Exists_impl {A} {P} {Q} H xs H0.

The second is a proof `Forall_inv_tail` that fills the gap left by
`Forall_inv`. It's proof is similarly easy:

    (**
      Accepts a predicate, [P], and a list, [x0 ::
      xs], and proves that if [P] is true for every
      element in [x0 :: xs], then [P] is true for
      every element in [xs].
    *)
    Definition Forall_inv_tail
      :  forall (A : Type) (P : A -> Prop) (x0 : A) (xs : list A),
    Forall P (x0 :: xs) -> Forall P xs
      := fun _ P x0 xs H
           => let H0
                :  forall x, In x (x0 :: xs) -> P x
                := proj1 (Forall_forall P (x0 :: xs)) H in
              let H1
                :  forall x, In x xs -> P x
                := fun x H2
                     => H0 x (or_intror (x0 = x) H2) in
              proj2 (Forall_forall P xs) H1.

    Arguments Forall_tail {A} {P} x0 xs.

At the moment, I've defined these proofs in a small personal library
that I include in most of my projects, but I'd like to see these
obvious extensions included in the Standard Library one day.

Who should a I propose these additions to? What are the rules for
adding theorems to the Coq Standard Library?

- Larry Lee




Archive powered by MHonArc 2.6.18.

Top of Page