Abstract
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.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsNotes
- 1.
In fact, regular languages (and several of the other examples above) form Kleene algebras, which essentially add to a star semiring the requirement that \(+\) is idempotent (\(a + a = a\)). However, for our purposes we do not need the extra restriction.
- 2.
Textbooks on automata often define the transition matrix for a DFA as the \(|Q| \times |\Sigma |\) matrix with its \(q,s\) entry equal to \(\delta (q,s)\). This is just a particular representation of the function \(\delta \), and quite uninteresting, so we co-opt the term transition matrix to refer to something more worthwhile.
- 3.
Typically we substitute the unit type for \( h \), but it makes the theory work more smoothly if we represent it initially with a unique type variable.
- 4.
Our notation is actually “backwards” with respect to the usual notation—what we write as \(f_{b,a}\) is often written \(f[a,b]\) or \([a,b]f\)—in order to better align with the combinatorial intuition discussed later.
References
Abbott, M., Altenkirch, T., McBride, C., Ghani, N.: \(\partial \) for data: differentiating data structures. Fundam. Inform. 65(1–2), 1–28 (2005)
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)
Droste, M., Kuich, W., Vogler, H. (eds.): Handbook of Weighted Automata. Springer Science & Business Media, Heidelberg (2009)
Duchon, P., Flajolet, P., Louchard, G., Schaeffer, G.: Boltzmann samplers for the random generation of combinatorial structures. Comb. Probab. Comput. 13(4–5), 577–625 (2004)
Huet, G.: Functional pearl: the zipper. J. Funct. Program. 7, 549–554 (1997)
Kleene, S.C.: Representation of events in nerve nets and finite automata. Technical report, DTIC Document (1951)
Lehmann, D.J.: Algebraic structures for transitive closure. Theor. Comput. Sci. 4(1), 59–76 (1977)
Marlow, S.: Haskell 2010 language report (2010). https://www.haskell.org/onlinereport/haskell2010/
McBride, C.: Clowns to the left of me, jokers to the right (pearl): dissecting data structures. In: POPL, pp. 287–295 (2008)
McBride, C., Paterson, R.: Applicative programming with effects. J. Funct. Program. 18(01), 1–13 (2008)
O’Connor, R.: A very general method for computing shortest paths (2011). http://r6.ca/blog/20110808T035622Z.html
Piponi, D.: Finite differences of types (2009). http://blog.sigfpe.com/2009/09/finite-differences-of-types.html
Piponi, D.: Constraining types with regular expressions (2010). http://blog.sigfpe.com/2010/08/constraining-types-with-regular.html
Piponi, D.: Divided differences and the tomography of types (2010). http://blog.sigfpe.com/2010/08/divided-differences-and-tomography-of.html
Sipser, M.: Introduction to the Theory of Computation. Cengage Learning, Boston (2012)
Siskind, J.M., Pearlmutter, B.A.: Nesting forward-mode ad in a functional framework. High.-Order Symb. Comput. 21(4), 361–376 (2008)
Stay, M., Jokers, Q., Clowns (2014). https://reperiendi.wordpress.com/2014/08/05/q-jokers-and-clowns/
Tarski, A.: A lattice-theoretical fixpoint theorem and its applications. Pac. J. Math. 5(2), 285–309 (1955)
Yorgey, B.A.: On a problem of SIGFPE (2010). https://byorgey.wordpress.com/2010/08/12/on-a-problem-of-sigfpe/
Acknowledgements
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.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2015 Springer International Publishing Switzerland
About this paper
Cite this paper
Piponi, D., Yorgey, B.A. (2015). Polynomial Functors Constrained by Regular Expressions. In: Hinze, R., Voigtländer, J. (eds) Mathematics of Program Construction. MPC 2015. Lecture Notes in Computer Science(), vol 9129. Springer, Cham. https://doi.org/10.1007/978-3-319-19797-5_6
Download citation
DOI: https://doi.org/10.1007/978-3-319-19797-5_6
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-19796-8
Online ISBN: 978-3-319-19797-5
eBook Packages: Computer ScienceComputer Science (R0)