Polynomial Functors Constrained by Regular Expressions
We show that every regular language, via some DFA which accepts it, gives rise to a homomorphism from the semiring of polynomial functors to the semiring of \(n \times n\) matrices over polynomial functors. Given some polynomial functor and a regular language, this homomorphism can be used to automatically derive a functor whose values have the same shape as those of the original functor, but whose sequences of leaf types correspond to strings in the language.
The primary interest of this result lies in the fact that certain regular languages correspond to previously studied derivative-like operations on polynomial functors, which have proven useful in program construction. For example, the regular language \(a^*ha^*\) yields the derivative of a polynomial functor, and \(b^*ha^*\) its dissection. Using our framework, we are able to unify and lend new perspective on this previous work. For example, it turns out that dissection of polynomial functors corresponds to taking divided differences of real or complex functions, and, guided by this parallel, we show how to generalize binary dissection to \(n\)-ary dissection.
KeywordsPolynomial Functors Regular expressions Differentiation Dissection
This work was partially supported by the National Science Foundation, under NSF 1218002, CCF-SHF Small: Beyond Algebraic Data Types: Combinatorial Species and Mathematically-Structured Programming.
Our sincere thanks to the anonymous reviewers, who had many helpful suggestions. Thanks also to Lukas Mai for pointing out some errors in a draft.
- 2.Stephen, D.: Fun with semirings: a functional pearl on the abuse of linear algebra. In: ACM SIGPLAN Notices, vol. 48, pp. 101–110. ACM (2013)Google Scholar
- 6.Kleene, S.C.: Representation of events in nerve nets and finite automata. Technical report, DTIC Document (1951)Google Scholar
- 8.Marlow, S.: Haskell 2010 language report (2010). https://www.haskell.org/onlinereport/haskell2010/
- 9.McBride, C.: Clowns to the left of me, jokers to the right (pearl): dissecting data structures. In: POPL, pp. 287–295 (2008)Google Scholar
- 11.O’Connor, R.: A very general method for computing shortest paths (2011). http://r6.ca/blog/20110808T035622Z.html
- 12.Piponi, D.: Finite differences of types (2009). http://blog.sigfpe.com/2009/09/finite-differences-of-types.html
- 13.Piponi, D.: Constraining types with regular expressions (2010). http://blog.sigfpe.com/2010/08/constraining-types-with-regular.html
- 14.Piponi, D.: Divided differences and the tomography of types (2010). http://blog.sigfpe.com/2010/08/divided-differences-and-tomography-of.html
- 15.Sipser, M.: Introduction to the Theory of Computation. Cengage Learning, Boston (2012)Google Scholar
- 17.Stay, M., Jokers, Q., Clowns (2014). https://reperiendi.wordpress.com/2014/08/05/q-jokers-and-clowns/
- 19.Yorgey, B.A.: On a problem of SIGFPE (2010). https://byorgey.wordpress.com/2010/08/12/on-a-problem-of-sigfpe/