Category Theory
Zulip Server
Archive

You're reading the public-facing archive of the Category Theory Zulip server.
To join the server you need an invite. Anybody can get an invite by contacting Matteo Capucci at name dot surname at gmail dot com.
For all things related to this archive refer to the same person.


Stream: practice: software

Topic: Differentiating Regex


view this post on Zulip James Fairbanks (Apr 16 2020 at 19:13):

Apparently you can "differentiate" a regex and get an efficient algorithm for matching them. This sounds like CT in disguise, http://matt.might.net/articles/implementation-of-regular-expression-matching-in-scheme-with-derivatives/ but I don't know how. Paging Dr. @Jules Hedges for a lensology consult.

view this post on Zulip sarahzrf (Apr 16 2020 at 19:14):

if it;s the same thing as this https://en.wikipedia.org/wiki/Brzozowski_derivative

view this post on Zulip sarahzrf (Apr 16 2020 at 19:15):

then it's the adjoint to day convolution

view this post on Zulip sarahzrf (Apr 16 2020 at 19:15):

but i was just leaving so i cant explain in detail rn :|

view this post on Zulip sarahzrf (Apr 16 2020 at 19:15):

day convolution in this case is concatenation of languages, though

view this post on Zulip sarahzrf (Apr 16 2020 at 19:16):

so this is the closed monoidal structure on the powerset of strings

view this post on Zulip sarahzrf (Apr 16 2020 at 19:18):

err sorry i was actually thinking of this https://en.wikipedia.org/wiki/Quotient_of_a_formal_language
but they are closely related

view this post on Zulip Gershom (Apr 17 2020 at 01:12):

Not deeply categorical but getting closer is rutten’s usage in discrete coinductive differential stream calculus https://www.cwi.nl/~janr/papers/files-of-papers/tcs308.pdf

view this post on Zulip sarahzrf (Apr 17 2020 at 01:19):

ok now i can say a bit more

view this post on Zulip sarahzrf (Apr 17 2020 at 01:20):

in (0, 0)-categories—i.e., sets (well, more or less)—the equivalent to taking the category of presheaves is taking the powerset

view this post on Zulip sarahzrf (Apr 17 2020 at 01:21):

the equivalent to the yoneda embedding is x{x}x \mapsto \{x\} and the equivalent of the yoneda lemma is xS    {x}Sx \in S \iff \{x\} \subseteq S

view this post on Zulip sarahzrf (Apr 17 2020 at 01:21):

now, a monoidal (0, 0)-category is just a monoid

view this post on Zulip sarahzrf (Apr 17 2020 at 01:23):

if you take the monoid Σ* of strings on some alphabet Σ, then day convolution on its "(0, 1)-category of presheaves" (powerset ordered under inclusion) looks like LK{s1s2s1L,s2K}L \otimes K \triangleq \{s_1 s_2 \mid s_1 \in L, s_2 \in K\}

view this post on Zulip sarahzrf (Apr 17 2020 at 01:25):

this is not symmetric monoidal—it's not a commutative monoid—so when i say it's closed i mean it has 2 different internal homs

view this post on Zulip sarahzrf (Apr 17 2020 at 01:27):

one satisfying LKO    LKOL \otimes K \subseteq O \iff L \subseteq K \multimap O and the other satisfying LKO    KL^OL \otimes K \subseteq O \iff K \subseteq L \mathrel{\hat\multimap} O

view this post on Zulip sarahzrf (Apr 17 2020 at 01:27):

these are the "quotients of a formal language" in that wikipedia article

view this post on Zulip sarahzrf (Apr 17 2020 at 01:28):

the brzozowski derivative is in particular the quotient of something by a singleton language—i.e., by the result of yoneda-embedding some string

view this post on Zulip sarahzrf (Apr 17 2020 at 01:30):

so the derivative of L with respect to a string s is gonna be y(s)^Ly(s) \mathrel{\hat\multimap} L

view this post on Zulip sarahzrf (Apr 17 2020 at 01:32):

incidentally, the | operator in regex is coproduct in this (0, 1)-category, and kleene star is taking the free monoid of something :-)

view this post on Zulip Philip Zucker (Apr 17 2020 at 03:32):

Following a link chain from Gershom's suggestion: https://ir.cwi.nl/pub/28550/ Rutten's recent textbook on coalgebra. has some category theory, automata, derivatives, what have you. Pretty interesting looking

view this post on Zulip Matteo Capucci (he/him) (Apr 17 2020 at 08:22):

Jeez, this thread is mind-blowing.

view this post on Zulip Matteo Capucci (he/him) (Apr 17 2020 at 08:23):

Is it just me or Brzozowski's derivative looks suspisciously like localization of a ring? Which, incidentally, is used by algebraic geometers to talk about derivatives

view this post on Zulip Matteo Capucci (he/him) (Apr 17 2020 at 08:26):

@sarahzrf I love your "low dimensional" category theory, it's incredible how seemingly advanced machinery was hiding in plain sight down in the (0,0)(0,0)/(0,1)(0,1) world

view this post on Zulip Jules Hedges (Apr 17 2020 at 10:17):

Pretty!

view this post on Zulip sarahzrf (Apr 17 2020 at 13:39):

come see my talk for the ACT seminar on the 6th then :-)

view this post on Zulip sarahzrf (Apr 17 2020 at 13:39):

unless i procrastinate too hard on making slides and have to bail :sob:

view this post on Zulip sarahzrf (Apr 17 2020 at 14:00):

regarding kleene star being free monoid:

view this post on Zulip sarahzrf (Apr 17 2020 at 14:01):

a monoid MM has morphisms IMI \to M and MMMM \otimes M \to M; at level (0, 1), this is all you need, because there can be only one choice for those morphisms, and all diagrams commute automatically—being a monoid is a property of an element in a monoidal proset, not a structure to equip it with

view this post on Zulip sarahzrf (Apr 17 2020 at 14:02):

the tensor unit in our monoidal proset is y(ε)y(\varepsilon), empty-string language

view this post on Zulip sarahzrf (Apr 17 2020 at 14:04):

so a language LL is a monoid if both

  1. y(ε)Ly(\varepsilon) \subseteq L, or equivalently εL\varepsilon \in L
  2. LLLL \otimes L \subseteq L

view this post on Zulip sarahzrf (Apr 17 2020 at 14:05):

i.e., if it parses the empty string and it parses any concatenation of things in itself

view this post on Zulip sarahzrf (Apr 17 2020 at 14:06):

then the sub-proset of P(Σ*) whose elements are the monoids is reflective—has a left adjoint to its inclusion, "taking the free monoid"

view this post on Zulip sarahzrf (Apr 17 2020 at 14:07):

the property is that for all languages LL and languages that are monoids MM, we have F(L)M    LMF(L) \subseteq M \iff L \subseteq M

view this post on Zulip sarahzrf (Apr 17 2020 at 14:08):

and of course L* is always a monoid for any L, so we can restrict it to a function of the right type; it is monotone; and it's not hard to check that it satisfies the property i just wrote

view this post on Zulip sarahzrf (Apr 17 2020 at 14:09):

so it's takng the free monoid!

view this post on Zulip sarahzrf (Apr 17 2020 at 14:10):

alternatively, observe that it literally is defined the same way as this construction of free monoids
image.png

view this post on Zulip Jesse Sigal (Apr 17 2020 at 15:04):

@sarahzrf wow, the "low dimensional" explanation is really cool. Have you seen this paper?

Change Actions: Models of Generalised Differentiation (https://arxiv.org/abs/1902.05465)

It gives a framework in which the derivative of regular expressions fit.

view this post on Zulip sarahzrf (Apr 17 2020 at 15:09):

i have not :eyes:

view this post on Zulip sarahzrf (Apr 17 2020 at 15:10):

also: hey neat to see you again :)

view this post on Zulip sarahzrf (Apr 17 2020 at 15:10):

you should come see my talk too

view this post on Zulip Jesse Sigal (Apr 17 2020 at 15:17):

sarahzrf said:

also: hey neat to see you again :)

Indeed, same :D

view this post on Zulip Jesse Sigal (Apr 17 2020 at 15:17):

Yep, ACT@UCR is on my google calendar :+1:

view this post on Zulip sarahzrf (Apr 17 2020 at 15:25):

for the record: the reason i had such a ready-made rant about this topic is that i've literally gone and formalized bits of it in coq before
image.png

view this post on Zulip sarahzrf (Apr 17 2020 at 15:26):

(language there is defined by Definition language : Type := PSh str.)

view this post on Zulip Christian Williams (Apr 17 2020 at 21:26):

This is great. The terminology coincides with the derivative of combinatorial species, which is also exponentiating by a representable: y(c)SS(c)y(c)\Rightarrow S \simeq S(c\otimes -). http://bergeron.math.uqam.ca/wp-content/uploads/2013/11/book.pdf

It's also useful for algebraic data types http://strictlypositive.org/calculus/;
and the derivative of operads describes variable binding, e.g. abs:(y(1)L)L\mathrm{abs}:(y(1)\Rightarrow L)\to L. https://homepages.inf.ed.ac.uk/gdp/publications/Abstract_Syn.pdf

@Conor McBride, do you have any thoughts as to how this notion of regex derivative is connected to the derivative of data types?

view this post on Zulip sarahzrf (Apr 17 2020 at 23:19):

i am reminded that the tangent bundle of a space is given by exponentiating it by a particular infinitesimal object

view this post on Zulip sarahzrf (Apr 17 2020 at 23:20):

that's a rather differential thing

view this post on Zulip sarahzrf (Apr 17 2020 at 23:20):

and representables are tiny, altho "infinitesimal" is maybe not appropriate here going by the definition im seeing when opening the nlab page again (it seems to be for cartesian closure), and anyway im not sure whether theyre infinitesimal here in addition to tiny, wld have to think about it

view this post on Zulip sarahzrf (Apr 18 2020 at 06:09):

re: derivative of operads, an operad is a monoid in species (where ⊗ is species composition), right?

view this post on Zulip sarahzrf (Apr 18 2020 at 06:09):

so derivative of species ~ derivative of operads?

view this post on Zulip sarahzrf (Apr 18 2020 at 06:10):

...oooooh that's the point you were making? >.<