Cellular automata (CA) are quintessential ALife and ubiquitous in many studies of collective behaviour and emergence, from morphogenesis to social dynamics and even brain modelling. Recently, there has been an increased interest in formalising CA, theoretically through category theory and practically in terms of a functional programming paradigm. Unfortunately, these remain either in the realm of simple implementations lacking important practical features, or too abstract and conceptually inaccessible to be useful to the ALife community at large. In this paper, we present a brief and accessible introduction to a category-theoretical model of CA computation through a practical implementation in Haskell. We instantiate arrays as comonads with state and random generators, allowing stochastic behaviour not currently supported in other known implementations. We also emphasise the importance of functional implementations for complex systems: thanks to the Curry-Howard-Lambek isomorphism, functional programs facilitate a mapping between simulation, system rules or semantics, and categorical descriptions, which may advance our understanding and development of generalised theories of emergent behaviour. Using this implementation, we show case studies of four famous CA models: first Wolfram's CA in 1D, then Conway's game of life, Greenberg-Hasings excitable cells, and the stochastic Forest Fire model in 2D, and present directions for an extension to N dimensions. Finally, we suggest that the comonadic model can encode arbitrary topologies and propose future directions for a comonadic network.
翻译:细胞自动机(CA)是人工生命研究中的典型范例,在从形态发生到社会动力学乃至脑建模的集体行为与涌现现象研究中无处不在。近年来,通过范畴论进行理论形式化以及基于函数式编程范式的实践形式化引起了日益增长的研究兴趣。然而,现有工作要么停留在缺乏重要实践特性的简单实现层面,要么过于抽象且概念艰深,难以被广大人工生命研究社区有效利用。本文通过Haskell中的实践实现,对CA计算的范畴论模型进行了简明易懂的引入。我们将数组实例化为带有状态和随机生成器的余单子,从而支持了当前其他已知实现中尚未具备的随机行为。同时,我们强调了函数式实现对于复杂系统的重要性:得益于Curry-Howard-Lambek同构,函数式程序能够促进仿真模拟、系统规则或语义与范畴描述之间的映射关系,这可能推动我们对涌现行为广义理论的理解与发展。基于此实现,我们展示了四个经典CA模型的案例研究:首先生成一维Wolfram CA,随后是二维Conway生命游戏、Greenberg-Hastings兴奋细胞模型以及随机森林火灾模型,并提出了向N维空间扩展的方向。最后,我们论证了余单子模型能够编码任意拓扑结构,并对余单子网络的未来研究方向提出了展望。