<div dir="ltr"><div>Thanks to all for those suggestions. I wound-up writing it from scratch, which was helpful in my learning reflection in agda. <br><br>"Reright" is now available on <a href="https://github.com/m0davis/agda-prelude">my fork</a> of agda-prelude. Some (very messy) sample code is <a href="https://github.com/m0davis/agda-prelude/blob/master/test/Reright.agda">here</a>. Due to <a href="https://github.com/agda/agda/issues/1833">issue #1833</a>, a parameter needs to be supplied to the macro, counting (roughly speaking) the number of arguments on the lhs.<br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">--<br>Martin Stone Davis<br><div><br>Postal/Residential:<br></div><div style="margin-left:40px"><span>1223 Ferry St</span><span><span><br></span></span></div><div style="margin-left:40px"><span><span>Apt 5<br></span></span></div><div style="margin-left:40px"><span>Eugene, OR 97401</span><br></div>Talk / <span></span>Text / Voicemail: <a href="tel:3106993578" value="+13106993578" target="_blank">(310) 699-3578</a><br>Electronic Mail: <a href="mailto:martin.stone.davis@gmail.com" target="_blank">martin.stone.davis@gmail.com</a><div><div><div><span></span></div></div></div></div></div><div dir="ltr"><span style="font-size:small">Website: </span><a href="http://martinstonedavis.com/" style="color:rgb(17,85,204);font-size:small" target="_blank">martinstonedavis.com</a></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Fri, Jan 22, 2016 at 4:51 AM, Victor Miraldo <span dir="ltr"><<a href="mailto:victor.cacciari@gmail.com" target="_blank">victor.cacciari@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Hello,<br><br></div>I did implement a library for doing exactly that as my Msc thesis. My code is not up-to-date with the new API for reflection aswell, <br></div>and, in fact, this new API provides a lot of interesting oportunities to improve it. If you're using a "not so recent" version of Agda<br></div>it might be worth to check it out.<br><br><a href="https://github.com/VictorCMiraldo/agda-rw" target="_blank">https://github.com/VictorCMiraldo/agda-rw</a><br><br></div>Cheers,<br></div>Victor<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 20, 2016 at 6:59 PM, Jesper Cockx <span dir="ltr"><<a href="mailto:Jesper@sikanda.be" target="_blank">Jesper@sikanda.be</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>I implemented a simple rewrite tactic using the reflection in Agda back in 2014, see <a href="https://lists.chalmers.se/pipermail/agda/2014/007032.html" target="_blank">https://lists.chalmers.se/pipermail/agda/2014/007032.html</a>. The code is not up-to-date with the new reflection API (and you could now probably make something that has a much nicer syntax anyway, using the new macro system) but it shows that there is nothing preventing you to do this using reflection. So I would say there is no need to implement something as a language extension if it is already possible as a library.<br><br></div>cheers,<br></div>Jesper<br></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 20, 2016 at 6:33 PM, Andrea Vezzosi <span dir="ltr"><<a href="mailto:sanzhiyan@gmail.com" target="_blank">sanzhiyan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Yes, having rewrite on the right would be very nice.<br>
<br>
It'd have to generate an helper like you did manually, that's how<br>
rewrite on the left is implemented too, so it might not make sense as<br>
an expression because it mangles the context, maybe it can have the<br>
same status as the macros of reflection.<br>
<br>
In your case you cannot really get away with just a subst, however you<br>
can get somewhere if you have proven that get commutes with subst, so<br>
you can fill the open goal here:<br>
<br>
(λ { gbx≡gax → trans gbx≡gax (trans (cong (subst V a≡b) gax≡gay) ?) })<br>
<br>
Best,<br>
Andrea<br>
<div><div><br>
<br>
<br>
<br>
<br>
<br>
On Wed, Jan 20, 2016 at 1:39 AM, Martin Stone Davis<br>
<<a href="mailto:martin.stone.davis@gmail.com" target="_blank">martin.stone.davis@gmail.com</a>> wrote:<br>
> I've found myself wishing that 'rewrite' or with-abstractions were invokable<br>
> from lambda expressions. A (contrived) case in point is as follows, where a<br>
> helper function is used to complete 'foo'. NB, I realize that, in this case,<br>
> I could have simply used a with-abstraction (as in 'bar'), but there are<br>
> other cases (not shown here) where one of the variables being ≟-compared<br>
> only exists on the rhs, thus requiring a call to 'case_of_'.<br>
><br>
> Is there a way to 'subst' my way out of the need for foo-helper?<br>
><br>
> module RewriteOnRight where<br>
> open import Data.Product using (∃ ; _,_)<br>
> open import Relation.Nullary using (Dec ; yes ; no)<br>
> open import Function using (case_of_)<br>
> open import Relation.Nullary.Negation using (contradiction)<br>
> open import Relation.Binary using (IsDecEquivalence)<br>
> open import Relation.Binary.PropositionalEquality using (_≡_ ; subst ;<br>
> trans ; refl)<br>
><br>
> postulate<br>
> K : Set<br>
> V : K → Set<br>
> M : Set<br>
> _∈_ : K → M → Set<br>
> get : ∀ {k : K} {m : M} → k ∈ m → V k<br>
> isDecEquivalence/K : IsDecEquivalence {A = K} _≡_<br>
><br>
> open IsDecEquivalence isDecEquivalence/K using (_≟_ ; sym)<br>
><br>
> foo-helper :<br>
> ∀ {x : M}<br>
> {y : M}<br>
> {a : K}<br>
> {b : K}<br>
> {a∈x : a ∈ x}<br>
> {b∈x : b ∈ x}<br>
> {a∈y : a ∈ y}<br>
> (gax≡gay : get a∈x ≡ get a∈y)<br>
> (a≡b : a ≡ b)<br>
> (gbx≡gax : get b∈x ≡ subst V a≡b (get a∈x))<br>
> → get b∈x ≡ get (subst (λ k → k ∈ y) a≡b a∈y)<br>
> foo-helper gax≡gay a≡b gbx≡gax rewrite a≡b = trans gbx≡gax gax≡gay<br>
><br>
> foo : ∀ {x : M}<br>
> {y : M}<br>
> (a : K)<br>
> (b : K)<br>
> {a∈x : a ∈ x}<br>
> {b∈x : b ∈ x}<br>
> {a∈y : a ∈ y}<br>
> (gax≡gay : get a∈x ≡ get a∈y)<br>
> → Dec (∃ λ (a≡b : a ≡ b) → (gbx≡gax : get b∈x ≡ subst V a≡b (get<br>
> a∈x)) → get b∈x ≡ get (subst (λ k → k ∈ y) a≡b a∈y))<br>
> foo a b gax≡gay = case a ≟ b of λ<br>
> { (yes a≡b) → yes (a≡b , (λ {gbx≡gax → foo-helper gax≡gay a≡b gbx≡gax}))<br>
> ; (no a≢b) → no (λ { (a≡b , _) → contradiction a≡b a≢b })<br>
> }<br>
><br>
> bar : ∀ {x : M}<br>
> {y : M}<br>
> (a : K)<br>
> (b : K)<br>
> {a∈x : a ∈ x}<br>
> (b∈x : b ∈ x)<br>
> {a∈y : a ∈ y}<br>
> (gax≡gay : get a∈x ≡ get a∈y)<br>
> → Dec (∃ λ (a≡b : a ≡ b) → (gbx≡gax : get b∈x ≡ subst V a≡b (get<br>
> a∈x)) → get b∈x ≡ get (subst (λ k → k ∈ y) a≡b a∈y))<br>
> bar a b _ _ with a ≟ b<br>
> bar _ ._ b∈x gax≡gay | yes refl = yes (refl , (λ {gbx≡gax → trans gbx≡gax<br>
> gax≡gay}))<br>
> bar _ _ _ _ | no a≢b = no (λ { (a≡b , _) → contradiction a≡b a≢b<br>
> })<br>
><br>
> --<br>
> Martin Stone Davis<br>
><br>
> Postal/Residential:<br>
> 1223 Ferry St<br>
> Apt 5<br>
> Eugene, OR 97401<br>
> Talk / Text / Voicemail: <a href="tel:%28310%29%20699-3578" value="+13106993578" target="_blank">(310) 699-3578</a><br>
> Electronic Mail: <a href="mailto:martin.stone.davis@gmail.com" target="_blank">martin.stone.davis@gmail.com</a><br>
> Website: <a href="http://martinstonedavis.com" rel="noreferrer" target="_blank">martinstonedavis.com</a><br>
><br>
</div></div>> _______________________________________________<br>
> Agda mailing list<br>
> <a href="mailto:Agda@lists.chalmers.se" target="_blank">Agda@lists.chalmers.se</a><br>
> <a href="https://lists.chalmers.se/mailman/listinfo/agda" rel="noreferrer" target="_blank">https://lists.chalmers.se/mailman/listinfo/agda</a><br>
><br>
_______________________________________________<br>
Agda mailing list<br>
<a href="mailto:Agda@lists.chalmers.se" target="_blank">Agda@lists.chalmers.se</a><br>
<a href="https://lists.chalmers.se/mailman/listinfo/agda" rel="noreferrer" target="_blank">https://lists.chalmers.se/mailman/listinfo/agda</a><br>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Agda mailing list<br>
<a href="mailto:Agda@lists.chalmers.se" target="_blank">Agda@lists.chalmers.se</a><br>
<a href="https://lists.chalmers.se/mailman/listinfo/agda" rel="noreferrer" target="_blank">https://lists.chalmers.se/mailman/listinfo/agda</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Agda mailing list<br>
<a href="mailto:Agda@lists.chalmers.se">Agda@lists.chalmers.se</a><br>
<a href="https://lists.chalmers.se/mailman/listinfo/agda" rel="noreferrer" target="_blank">https://lists.chalmers.se/mailman/listinfo/agda</a><br>
<br></blockquote></div><br></div>