Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] generalized rewriting question

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] generalized rewriting question


Chronological Thread 
  • From: Pierre Courtieu <pierre.courtieu AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] generalized rewriting question
  • Date: Fri, 15 Mar 2019 10:09:08 +0100
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=pierre.courtieu AT gmail.com; spf=Pass smtp.mailfrom=pierre.courtieu AT gmail.com; spf=None smtp.helo=postmaster AT mail-it1-f181.google.com
  • Ironport-phdr: 9a23:YVJz8BLVKzEdliLroNmcpTZWNBhigK39O0sv0rFitYgRLPnxwZ3uMQTl6Ol3ixeRBMOHsqoC07OempujcFRI2YyGvnEGfc4EfD4+ouJSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47xaFLIv3K98yMZFAnhOgppPOT1HZPZg9iq2+yo9JDffhlEiCChbb9vMR67sRjfus4KjIV4N60/0AHJonxGe+RXwWNnO1eelAvi68mz4ZBu7T1et+ou+MBcX6r6eb84TaFDAzQ9L281/szrugLdQgaJ+3ART38ZkhtMAwjC8RH6QpL8uTb0u+ZhxCWXO9D9QLYpUjqg8qhrUgflhygJNzE78G/ZhM9+gr9Frh29vBFw2ZLYbZuPOfZiYq/Qf9UXTndBUMZLUCxBB5uxYZEOD+UfJ+ZYtZfyrEYQoBu5GAmsHv/vyj5WiX/rwKY31PwhEQDY0ww6BdIBrm7Yo8nyNKcPS+C10KjIwiveb/5N1jf97ZLHchElof2WQb1wds/RxFApGgjYgFuQronlMCmU1uQLq2Wa4fJgVeO1h2E5tg5xvz6izdovhInRno8Z1EzI+CFjzIs2JdC0UlN3bN+lHZdKqi2XNJZ6T8U/SG9yoik60KcJuZujcSgK1psnwxnfZuSCc4eS4xLjUP+dITZkhH54Yb6/iQu+/Eu9xuHmWcm011FKriVBktbSrHwCyxvT6s2fRvt8+EeuxyqP2hjN5u1YJU04j6nWJp47zrItl5cesF7PEjL1lUnrlKOWc18r+ums6+TpeLXmoZqcOpdsigH/LKsugNa/DvoiPgcSWGib5P681KHi/ULnXbVHlfI2kqzDv5DbIcQXvLK2AwhQ0oo78RawEy+m0MgEnXkANF9KZBWHj5HwN17SJPD4EOywjk+3kDZrwvDGJqfuDo/MLnjFirfhfKxy51RSyAopnphj4MdfDahEK/buUGfwssbZB1k3KV+a2eHiXe1825kEVCqkBbKDLKLfrBfc/uMiOfOBIoQSpSzhKvU4z/HrhH4931QaeP/6jtMsdHmkE6E+cA2ian32j4JZSDZYjk8FVOXvzWa6f3tWbne2Ubg742hiWo2jBIbHAIuqhe7YhXvpLthtfmlDT2u0PzLwbYzdAqUDbSuTJolqlTlWDeH8Gb9k7gmnsUrB85QiLufQ/XdG55fq1dww5vGK0B9rpWUyAMOa3GWACWpzmzFQSg==

I guess you need to define a relation for the list of terms. Something like:

C1: eqv x x’ -> like x::l == x’::l
C2:l ==l’ -> x::l ==x::l’
Ctrans: ...

P

Le ven. 15 mars 2019 à 07:59, Dan Dougherty <dougherty.dan AT gmail.com> a écrit :
(* Hi all,

I'm having trouble setting up a generalized (setoid) rewriting
mechanism.  A simplified version of my setting is as follows.

I'm working with first order terms and an inductive relation defining
provable equality based on some axioms, and I want to be able to
rewrite modulo that relation.  All is straightforward if I define
terms using the function symbols as constructors (see the second
snippet) but I'd prefer to define terms more generally using the first
"term" definition below.

My question is, how can I define a parametric morphism, analogous to
what is done for A' and Lemma ok in the latter snippet, that allows
rewriting to succeed in Lemma not_ok?

thanks in advance,
Dan
*)
Require Export List.
Export ListNotations.
Require Export Setoid.
Require Export SetoidClass.
Require Export Morphisms.

Inductive FunSym : Type := A | M.

Inductive term: Type :=
| V : nat -> term
| T : FunSym -> list term -> term .

Inductive eqv : term -> term -> Prop :=
 (* some equations ...*)

| eqv_ref:   forall x,  eqv x x
| eqv_sym:   forall x y,  eqv x y -> eqv y x
| eqv_trans: forall x y z,  eqv x y -> eqv y z -> eqv x z

| A_compat : forall x x' ,
    eqv x x' -> forall y y' ,
    eqv y y' -> eqv (T A [x ; y] ) (T A [x' ;  y']).
Hint Constructors eqv.

Add Parametric Relation  : term eqv
    reflexivity proved by @eqv_ref
    symmetry proved by @eqv_sym
    transitivity proved by @eqv_trans
      as eqv_rel.

(* MY QUESTION: how to add some parametric morphism so that rewrites
like the following succeed? *)

Lemma not_ok : forall x x' y,
  eqv x x' ->
  eqv (T A [x;y]) (T A [x'; y]).
Proof.
  intros x x' y H.
  try rewrite H.
Abort.

(* ********* below works fine ****************** *)

Inductive term' : Type :=
| V' : nat -> term'
| A'  :  term' -> term' -> term' .

Inductive eqv' : term' -> term' -> Prop :=
 (* some equations ...*)

| eqv'_ref:   forall x,  eqv' x x
| eqv'_sym:   forall x y,  eqv' x y -> eqv' y x
| eqv'_trans: forall x y z,  eqv' x y -> eqv' y z -> eqv' x z

| A'_compat : forall x x' ,
    eqv' x x' -> forall y y' ,
    eqv' y y' -> eqv' (A' x y) (A' x' y').
Hint Constructors eqv'.

Add Parametric Relation  : term' eqv'
    reflexivity proved by @eqv'_ref
    symmetry proved by @eqv'_sym
    transitivity proved by @eqv'_trans
      as eqv'_rel.

Add Parametric Morphism : A' with
      signature eqv' ==> eqv' ==> eqv' as A'_mor.
  exact A'_compat.
Qed.

Lemma ok : forall x x' y,
  eqv' x x' ->
  eqv' (A' x y) (A' x' y).
Proof.
  intros x x' y H.
  now rewrite H.
Qed.


--
Dan Dougherty
231 Fuller Labs
Worcester Polytechnic Institute

WPI Department of Computer Science:
    http://web.cs.wpi.edu/~dd/
Ombuds:
    http://www.wpi.edu/offices/ombuds/



Archive powered by MHonArc 2.6.18.

Top of Page