Skip to Content.
Sympa Menu

coq-club - [Coq-Club] help please with development in Coq

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] help please with development in Coq


Chronological Thread 
  • From: Norman Rink <norman.rink AT tu-dresden.de>
  • To: <coq-club AT inria.fr>
  • Subject: [Coq-Club] help please with development in Coq
  • Date: Tue, 05 Feb 2019 10:59:19 +0100
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=norman.rink AT tu-dresden.de; spf=None smtp.mailfrom=norman.rink AT tu-dresden.de; spf=None smtp.helo=postmaster AT mailout6.zih.tu-dresden.de
  • Ironport-phdr: 9a23:RqX3ahJcECCOolHD6NmcpTZWNBhigK39O0sv0rFitYgeK/nxwZ3uMQTl6Ol3ixeRBMOHs6IC07KempujcFRI2YyGvnEGfc4EfD4+ouJSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47xaFLIv3K98yMZFAnhOgppPOT1HZPZg9iq2+yo9JDffwZFiCChbb9uMR67sRjfus4KjIV4N60/0AHJonxGe+RXwWNnO1eelAvi68mz4ZBu7T1et+ou+MBcX6r6eb84TaFDAzQ9L281/szrugLdQgaJ+3ART38ZkhtMAwjC8RH6QpL8uTb0u+ZhxCWXO9D9QLYpUjqg8qhrUgflhykJOTAk8G/ZlM9+g61HrxyuvBF/35fUYISJOPZiZK7Qf9UXTndBUMZLUCxBB5uxYZMID+obOOZXtY/9rEYSoxu/AwmsB/7kxzhOhn/xx6061v4uEQfc0Aw6HtIOtnfUoc7pNKcPSOy60bPIwivYb/xLxzj97pLEfQ0/rvyVW797bMTfyU4qFwzfj1WQr5ToPy+I1ugUrmeb9fRvVfmyhGE5rQF9uCWgydk0hobVhoIVzlHE9T1jz4YxP9K0Ukh7bsC4EJZWqiqUNJN2T9s/T2xnpSo20LMLtYKhcCULypkr3RzSZvyff4SV7R/vSfydLDlkiH5/eL+zmQy+/VW+xuD6S8K6ykxFrjBfndnJrn0N1wLc6syASvZl+0euwzeP1wTU6uFZPUA5lLDXKp8gwr4wjJYTrVnDEjbrl0XskqCWbVgr9fau6+j9f7rpuIeQN45yig7gLqQjgtGzDOslPgQUUWWX5f6w2bzh8EHjQrhHjuU6kqzDv5DbIcQbqLS5AwhQ0os77Ra/CC2m0NECknkBNl5FYhOHj47qO1zVPPD4EO6zjEm2kDh13PDJI6PuApPXInfejrjtZax95FJEyAov0dBf4IpZBa0GIPLqQ0P+qNjYDgIiPAGv2ObmCNB91psEVm6VA6+ZNrnSsV6S6e41LemMftxdhDGof/Mi/rvliWIzsV4bZ6igm5UNPiOWBPNjdmOee3/lhJ87EGEJ9l44S/bvgVvESz9VZF6uQucw/DwgBI+gS4vOENP+yIed1Tu2S8UFLltNDUqBRC+xJte0HswUYSfXGfdP1zkNVLyvUYgkjEz8qBK/x6BqNebZ/GsUuMC7jYQn16jojRg3sAdMIYGFyWjUEjNogyYEXTIt0K1550BwmA/ajPpIxsdAHNkW3MtnFwc3MZmGn75/AtH2XR/dIJGbSVbgXsjjDSs8Vd48xZkCbhQlFg==

Dear Coq-club,

I am relatively new to Coq. While I feel comfortable with “pedestrian”-style
Coq developments – by which I mean specifying comparably simply-typed
functions in Gallina and proving theorems about these functions outside of
the definitions – I am now trying to use Coq/Gallina more effectively by
writing dependently-typed functions (hoping that this will save some
outside-of-definitions proof effort).

In this context, I would like to introduce my own tuples, i.e. lists of fixed
finite length. For these tuples, I then want to introduce “typical” list
functions like ‘append’, ‘tail’ etc. My tuple definition and ‘tail’ function
appear below.

Definition MyTuple (n:nat) := { l:list nat | length l = n }.

Definition tail {n:nat} : MyTuple (S n) -> MyTuple n.
Proof.
refine(match n with
| 0 => fun _ => exist _ [] eq_refl
| S n' => fun t => _
end).
destruct t.
destruct x.
inversion e.
inversion e. exists x. reflexivity.
Defined.

Since the definition of ‘tail’ is a little non-transparent (and the code for
the proof is quite cryptic – try printing it), I am compelled to verify that
my ‘tail’ function behaves as expected. This means I want my taking-the-tail
operation to commute with projecting the list out of ‘MyTuple’, i.e.:

Lemma tail_correct : forall (n:nat) (t:MyTuple (S n)),
proj1_sig (tail t) = tl (proj1_sig t).

When attempting to prove this lemma (by induction on n), I run into the
problem that I would like to “destruct” an equality proof ‘e’:

e : length (n0 :: x) = S (S n)

The only constructor for ‘e’ is of course ‘eq_refl’, but I cannot seem to
convince Coq of this since ‘eq_refl’ has type ‘x = x’ while my ‘e’ from above
is typed at ‘length (n0 :: x) = S (S n)’. I wonder if there is anything that
I am obviously doing wrong.

I am aware of the discussion of similar looking issues in Chapter 10 of the
CPDT book. http://adam.chlipala.net/cpdt/
However, the techniques from there (proof irrelevance, ’UIP’, ‘StreicherK’)
do not quite seem to work for me since all of them eventually talk about
proofs of ‘x = x’. (Heterogeneous equality ‘JMeq’ also does not seem to be a
good fit since it appears that ‘JMeq’ can be put to use most effectively if
it is indeed used at the same types eventually.)

In case anyone feels compelled to suggest I use finite-length vectors instead
of subtypes of lists: I ultimately run into similar problems with equality
between different types (not for the ‘tail’ function specifically but in
attempted proofs of lemmas similar to “tail_correct” above). It would be
great if I could somehow eliminate ‘eq_rec’/‘eq_rect’ from terms in my
proofs, but I understand that this is a bit of a rush (wishful) fix.

Any help or pointers would be greatly appreciated. Many thanks.

Best regards,

Norman Rink



Dr. Norman Rink
Postdoctoral Researcher

Technische Universität Dresden
Faculty of Computer Science
Chair for Compiler Construction
Helmholtzstrasse 18
Barkhausenbau, BAR III.59
01062 Dresden

phone: +49 (0)351 463 43711
email:
norman.rink AT tu-dresden.de
www: https://cfaed.tu-dresden.de/ccc-staff-rink








Archive powered by MHonArc 2.6.18.

Top of Page