coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Maximilian Wuttke <mwuttke97 AT posteo.de>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Recursive Notation in Coq
- Date: Tue, 28 Jul 2020 15:08:43 +0200
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=mwuttke97 AT posteo.de; spf=Pass smtp.mailfrom=mwuttke97 AT posteo.de; spf=None smtp.helo=postmaster AT mout01.posteo.de
- Ironport-phdr: 9a23:/6+0Gh3tCfeVws44smDT+DRfVm0co7zxezQtwd8ZseIQLvad9pjvdHbS+e9qxAeQG9mCtbQa0aGL7OjJYi8p2d65qncMcZhBBVcuqP49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6JvjvGo7Vks+7y/2+94fcbglVhTexe7J/IAu5oQjRtMQdnJdvJLs2xhbVuHVDZv5YxXlvJVKdnhb84tm/8Zt++ClOuPwv6tBNX7zic6s3UbJXAjImM3so5MLwrhnMURGP5noHXWoIlBdDHhXI4wv7Xpf1tSv6q/Z91SyHNsD4Ubw4RTKv5LptRRT1iikIKiQ5/XnKhMJugqJVoBGvqRJxzIHbYo6aKPVwc7jBfd4ZX2dNQtpdWiJDD466coABD/ABPeFdr4TloFUBtxS/BQipBOPuzj9Ih2X53asn2OshDAHGwBAgH9EQv3/Jq9j1MakTUf2pzKnUzjXMcfdb1DXm5YjQdRAhuu2MUqx3ccbL1EYgCRrIg1ONooPqIz2bzP4Cs3SH7+V+T+KvjXYqpxx+rDag28shlIjEipwLx13Z+ih0z4Q4KN6lRENmbtOoDoZcuiKZOoV2Xs8uXn9ltTo4x7MGu5O2YTQHxYojyhPZdveJfY+I4hf5W+aQJzd1nG9qeLOkhxmu9kig1/f8VtKq31pQoSpFiN7Mtm0V1xHV98OJSeN981+81TuM1w3f8OBJLEIumafVKpMt2L89m5oLvUnAGiL6glj6gaCXe0k+5OSk9fjrbq/7qpKSK4N5jBz1PL40lcylG+s4NxADX2iF9uS4073u5Uj5QLJXjv0qjqXVrYrWJdwcpq6iHw9azIEj5wyiADi4yNgYnH8HI0xZeB+fkoTkOFHDLOr5APq9mVihnjZmy+rHM7DhGpnNK2LMkLblfbZz8U5czw8zwMha55NaF7EBPO7zWkzvu9HcDBI0KBS0w+H8CNVhyIweXniDDbKHP6/Kq1+H+vovI/WQZI8SoDvyN/8l5+f3gXAlnV8dYLKm0IAMaHG4G/RmO1+WbWDtgtcHC2cKvxAxQPbkiF2YAnZvYCO5WLt57TUmAqqnC53CT8ajmu+vxiC+S7hfdmFDC1SNGHGgSJiYR/QBIHaXPdJ9jj8JBOeJU4g6yRyp8gP3nek0ZtHI8zEV4MqwnON+4PfewElrpG5ESv+F2mTIdFla22YBRjs4xqd6+BUv0lCYzaV/xfBVR4UKuqF5FzwiPJuZ9NRUTtD/XgWYLoWMT0u6GozgGTYqUt82hdMDMR4kR4eSyyvb1i/vOIc70qSRDcVtoLrbxGT8IIBxxiSe2Q==
Hi Club,
In addition to the solution I posted on Discourse [1], here's an
implementation of Adam's idea:
```
Fixpoint chainToProp {X : Type} (R : X->X->Prop) (xs : list X) : Prop :=
match xs with
| nil => True
| x :: xs =>
match xs with
| nil => True
| y :: nil => R x y
| y :: _ => R x y /\ chainToProp R xs
end
end.
Notation "'chain' xs 'endchain'" := (ltac:(let x := eval cbv
[chainToProp] in (chainToProp le xs) in exact x)) (only parsing).
Check chain [1;2;3;4] endchain.
(* 1 <= 2 /\ 2 <= 3 /\ 3 <= 4 *)
(* : Prop *)
```
[1]: <https://coq.discourse.group/t/notation-for-inequality-chain/979/2>
On 28/07/2020 14:44, Adam Chlipala wrote:
> My guess is that (1) you may need to add some kind of brackets around
> the notation, and (2) you may need to build a Gallina list of the
> different elements and then apply a Gallina function that checks
> relatedness of adjacent elements. There is indeed a built-in notation
> facility for variable-length forms, but I don't think it allows
> constructing subterms out of adjacent parts of the original argument
> list, and it doesn't allow referencing the same notation recursively in
> the expansion.
>
> On 7/28/20 8:39 AM, Dominique Larchey-Wendling wrote:
>> Dear all,
>>
>> If a notations wizard could help me at defining
>> the following recursive notation in Coq, I would
>> be very grateful.
>>
>> x ⪯ y ⪯ .. ⪯ z := red x y /\ y ⪯ .. ⪯ z
>>
>> where red : _ -> _ -> Prop
>>
>> ie
>>
>> a ⪯ b ⪯ c ⪯ d would be (red a b) /\ (red b c /\ red c d).
>>
>> Sequences must have length >=2 (otherwise they would be meaningless)
>>
>> Thank you very much for some insights,
>>
>> Dominique
>
>
- [Coq-Club] Recursive Notation in Coq, Dominique Larchey-Wendling, 07/28/2020
- Re: [Coq-Club] Recursive Notation in Coq, Adam Chlipala, 07/28/2020
- Re: [Coq-Club] Recursive Notation in Coq, Maximilian Wuttke, 07/28/2020
- Re: [Coq-Club] Recursive Notation in Coq, Adam Chlipala, 07/28/2020
- Re: [Coq-Club] Recursive Notation in Coq, Dominique Larchey-Wendling, 07/28/2020
- Re: [Coq-Club] Recursive Notation in Coq, Adam Chlipala, 07/28/2020
- Re: [Coq-Club] Recursive Notation in Coq, Maximilian Wuttke, 07/28/2020
- Re: [Coq-Club] Recursive Notation in Coq, Dominique Larchey-Wendling, 07/28/2020
- Re: [Coq-Club] Recursive Notation in Coq, Hugo Herbelin, 07/29/2020
- Re: [Coq-Club] Recursive Notation in Coq, Dominique Larchey-Wendling, 07/29/2020
- Re: [Coq-Club] Recursive Notation in Coq, Hugo Herbelin, 07/29/2020
- Re: [Coq-Club] Recursive Notation in Coq, Dominique Larchey-Wendling, 07/28/2020
- Re: [Coq-Club] Recursive Notation in Coq, Maximilian Wuttke, 07/28/2020
- Re: [Coq-Club] Recursive Notation in Coq, Adam Chlipala, 07/28/2020
- Re: [Coq-Club] Recursive Notation in Coq, Dominique Larchey-Wendling, 07/28/2020
- Re: [Coq-Club] Recursive Notation in Coq, Maximilian Wuttke, 07/28/2020
- Re: [Coq-Club] Recursive Notation in Coq, Adam Chlipala, 07/28/2020
Archive powered by MHonArc 2.6.19+.