Skip to Content.
Sympa Menu

coq-club - [Coq-Club] Dealing with equalities in dependent types

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] Dealing with equalities in dependent types


Chronological Thread 
  • From: Klaus Ostermann <klaus.ostermann AT uni-tuebingen.de>
  • To: coq-club AT inria.fr
  • Subject: [Coq-Club] Dealing with equalities in dependent types
  • Date: Fri, 20 Jan 2017 11:45:34 +0100
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=klaus.ostermann AT uni-tuebingen.de; spf=None smtp.mailfrom=klaus.ostermann AT uni-tuebingen.de; spf=None smtp.helo=postmaster AT mx04.uni-tuebingen.de
  • Ironport-phdr: 9a23:zYzcyRfqLQUcm6yXUPvHs/AXlGMj4u6mDksu8pMizoh2WeGdxcuyYR7h7PlgxGXEQZ/co6odzbGH7+a8AidZut6oizMrSNR0TRgLiMEbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpTEdFQ/iOgVrO+/7BpDdj9it1+C15pbffxhEiCCzbL52Ixi6twrcu8cZjYd/JKs61wfErGZPd+lK321jOEidnwz75se+/Z5j9zpftvc8/MNeUqv0Yro1Q6VAADspL2466svrtQLeTQSU/XsTTn8WkhtTDAfb6hzxQ4r8vTH7tup53ymaINH2QLUpUjms86tnVBnlgzoBOjUk8m/Yl9ZwgbpFrhyhuhJxwIDab4+aO/Vica3QZs8aRXNbU8pNSyBMDIGxYo0SBOQBJ+ZYqIz9qkMLoxu6HwasGfjvwSJRiH/twa01zf4hEQTc0wwmGdIFrXPZrNbxNKgITOC117PEzTLYb/NKxzj98o3IfQonofGKRr9wbMzRyUg2GwPZk1Wft5fqPzKT1uQCrWeb6fBsWv+xhGM+rQx6vzuhxt80h4XUiI8YxUrI+TtjzIs1P9G0VlN3bNG8HJdNuSyXOJF6Tt04T211pio20KAKtJ6ncCUM1Z8p3QTQa+adfIiN+h/jVPieITN/hH99fbK+iAq+/Ee6xu3hUMm00U9GrjZYktbSrX8N1hrT6seZRft75EuuxCiA2xjS6uFCP080ibLWJ4Mvz7M/jJYfr17PEy/slEnokaObeV0o+u2y5OTmZrXmqIWcN4hxigzmMaQuntawAfkjMgQUWGib4vi826P5/U38WrpKiPs2n7LEsJDcJMQXv7K5AxJL3Yk46ha/CTim38oenXUdMV1KZgqLj5L1NFHWPPD4EfC/jkywnzds3vDKJ6HuApHQLnfYi7rhZrZ860tEyAUp19xf5pRUCqsAIP3pQEPxusbYXVcFNFm/xP+iA9Fg3KsfX3iOC+mXKvD8q1iNs8ErKvSXLKgOpDvnLvEj4ba6jnswhERberK10IESYXa+NulgIgCFfHfmg9EOHGFMsgdoH7+is0GLTTMGPyX6ZKk7/DxuUI8=

I want to state (and prove) a lemma that conversion of
lists to vectors commutes with mapping.

Hence my lemma should look something like this:

Lemma vmap_map: forall {A B}{f : A -> B}{ l: list A},
Vector.map f (Vector.of_list l) = Vector.of_list (map f l).

This lemma is not accepted by Coq because:

> The term "Vector.of_list (map f l)" has type "Vector.t B (length (map
f l))"
> while it is expected to have type "Vector.t B (length l)".

There's a lemma in the standard library, which proves the required
equality, namely map_length:

map_length
: forall (A B : Type) (f : A -> B) (l : list A),
length (map f l) = length l

But how can I tell Coq that it should accept my lemma due to map_length?

One thing I tried was to reformulate the lemma using an explicit auxiliary
congruence lemma:

Lemma eq_cong: forall {A} {x : A} {y : A} P, x = y -> P x -> P y.

With this auxiliary Lemma, I can reformulate map_vmap in such a way
that Coq accepts the lemma:

Lemma vmap_map: forall {A B}{f : A -> B}{ v: list A},
Vector.map f (Vector.of_list v) = eq_cong (Vector.t B) (map_length f v)
(Vector.of_list (map f v)).

However, it's no longer the same lemma, and it's awkward to use.

Presumably I'm missing something very obvious, but I'd be grateful for
suggestions.

Klaus








Archive powered by MHonArc 2.6.18.

Top of Page