<div dir="auto">Thank you! Are you going to add a place for auxiliary definitions? Perhaps also a few default definitions like lambdabot uses? As it is, there doesn't seem to be a way to use non-Prelude to constructors. One more thing, that was missing from the original: a good explanation of what the output means. "lift" is particularly mysterious. Lambdabot seems to replace these with calls to normal Haskell functions. Perhaps that can be done sometimes? One last thing: the FRP interface seems a bit *too* responsive. It's not fun to see error messages flashing on and off as I type. Perhaps it would make sense to add a delay before activating one of those?</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jul 24, 2018, 1:38 PM Joachim Breitner <<a href="mailto:mail@joachim-breitner.de">mail@joachim-breitner.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I felt inspired to revive the free theorem calculator and gave it a new<br>
home (and a modern, browser-only, FRP-based implementation):<br>
<br>
<a href="http://free-theorems.nomeata.de/" rel="noreferrer noreferrer" target="_blank">http://free-theorems.nomeata.de/</a><br>
<br>
which prints<br>
<br>
forall t1,t2 in TYPES, R in REL(t1,t2).<br>
forall (x, y) in lift{(,)}(id,R).<br>
(g_{t1} x, g_{t2} y) in lift{(,)}(id,R)<br>
<br>
as the free theorem, which is (if one squints) the same as my <br>
<br>
∀ z z' Rz, ∀ a x x', x Rz x' →<br>
fst (g (a,x)) = fst (g (a,x')) ∧ snd (g (a,x)) Rz snd (g (a,x'))<br>
<br>
Enjoy,<br>
Joachim<br>
<br>
Am Montag, den 23.07.2018, 10:56 -0700 schrieb Conal Elliott:<br>
> Thank you, Joachim! I'm refreshing my memory of free theorem construction from that blog post. Regards, -- Conal<br>
> <br>
> On Mon, Jul 23, 2018 at 8:33 AM, Joachim Breitner <<a href="mailto:mail@joachim-breitner.de" target="_blank" rel="noreferrer">mail@joachim-breitner.de</a>> wrote:<br>
> > Hi Conal,<br>
> > <br>
> > Am Sonntag, den 22.07.2018, 21:29 -0700 schrieb Conal Elliott:<br>
> > > Suppose `g :: forall z. (A,z) -> (B,z)`. Is it necessarily the case<br>
> > > that `g = first f` for some `f :: A -> B` (where `first f (a,b) = (f<br>
> > > a, b)`), perhaps as a free theorem for the type of `g`?<br>
> > <br>
> > there used to be a free theorem calculator at<br>
> > <a href="http://www-ps.iai.uni-bonn.de/ft" rel="noreferrer noreferrer" target="_blank">http://www-ps.iai.uni-bonn.de/ft</a><br>
> > but it seems to be down :-(<br>
> > <br>
> > There is a shell client, ftshell, lets see what it says…<br>
> > it does not build with ghc-8.0 any more :-(<br>
> > <br>
> > Ah, but lambdabot understands @free:<br>
> > <br>
> > <nomeata> @free g :: forall z. (A,z) -> (B,z)<br>
> > <lambdabot> $map_Pair $id f . g = g . $map_Pair $id f<br>
> > <br>
> > Which is basically what you are writing here:<br>
> > <br>
> > > Note that `(A,)` and `(B,)` are functors and that `g` is a natural<br>
> > > transformation, so `g . fmap h == fmap h . g` for any `h :: u -> v`.<br>
> > > Equivalently, `g . second h == second h . g` (where `second h (a,b) =<br>
> > > (a, h b)`).<br>
> > <br>
> > Doesn’t that already answer the question? Let’s try to make it more<br>
> > rigorous. I define<br>
> > <br>
> > f :: A -> B<br>
> > f a = fst (g (a, ())<br>
> > <br>
> > and now want to prove that g = first f, using the free theorem… which<br>
> > is tricky, because the free theorem is actually not as strong as it<br>
> > could be; it should actually be phrased in terms of relations relation,<br>
> > which might help with the proof. <br>
> > <br>
> > So let me try to calculate the free theorem by hand, following<br>
> > <a href="https://www.well-typed.com/blog/2015/05/parametricity/" rel="noreferrer noreferrer" target="_blank">https://www.well-typed.com/blog/2015/05/parametricity/</a><br>
> > <br>
> > g is related to itself by the relation<br>
> > <br>
> > [forall z. (A,z) -> (B,z)]<br>
> > <br>
> > and we can calculate<br>
> > <br>
> > g [forall z. (A,z) -> (B,z)] g<br>
> > ↔ ∀ z z' Rz, g [(A,z) -> (B,z)] g -- Rz relates z and z'<br>
> > ↔ ∀ z z' Rz, ∀ p p', p [(A,z)] p' → g p [(B,z)] g p'<br>
> > ↔ ∀ z z' Rz, ∀ p p', fst p = fst p' ∧ snd p Rz snd p' →<br>
> > fst (g p) = fst (g p') ∧ snd (g p) Rz snd (g p')<br>
> > ↔ ∀ z z' Rz, ∀ a x x', x Rz x' →<br>
> > fst (g (a,x)) = fst (g (a,x')) ∧<br>
> > snd (g (a,x)) Rz snd (g (a,x'))<br>
> > <br>
> > We can use this to show<br>
> > <br>
> > ∀ (a,x :: z). fst (g (a,x)) = f a<br>
> > <br>
> > using (this is the tricky part that requires thinking)<br>
> > <br>
> > z := z, z' := (), Rz := λ_ _ -> True, a := a, x := x, x' := ()<br>
> > <br>
> > as then the theorem implies<br>
> > <br>
> > fst (g (a,x)) = fst (g (a, ()) = f a.<br>
> > <br>
> > We can also use it to show <br>
> > <br>
> > ∀ (a,x :: z). snd (g (a,x)) = x<br>
> > <br>
> > using<br>
> > <br>
> > z := z, z' := z, Rz := const (= x), a := a, x := x, x' := x<br>
> > <br>
> > as then the theorem implies, under the true assumption x Rz z'<br>
> > <br>
> > (snd (g (a,x))) Rz (snd (g (a,x')))<br>
> > ↔ snd (g (a,x)) = x<br>
> > <br>
> > And from <br>
> > <br>
> > ∀ (a,x :: z). fst (g (a,x)) = f a<br>
> > ∀ (a,x :: z). snd (g (a,x)) = x<br>
> > <br>
> > we can conclude that<br>
> > <br>
> > g = first f<br>
> > <br>
> > as intended.<br>
> > <br>
> > Cheers,<br>
> > Joachim<br>
> > <br>
> > <br>
> > <br>
> > _______________________________________________<br>
> > Haskell-Cafe mailing list<br>
> > To (un)subscribe, modify options or view archives go to:<br>
> > <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
> > Only members subscribed via the mailman list are allowed to post.<br>
-- <br>
Joachim Breitner<br>
<a href="mailto:mail@joachim-breitner.de" target="_blank" rel="noreferrer">mail@joachim-breitner.de</a><br>
<a href="http://www.joachim-breitner.de/" rel="noreferrer noreferrer" target="_blank">http://www.joachim-breitner.de/</a><br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>