arXiv:2610.20821cs.LOOct 2026

Manuscript Offprint

arXiv:2610.20821

Automating Observable Closure Analysis for Graph Transformation Models with MolFoundry

Marcel Friedrichs, Addie Jordon, Juri Kolčák, Daniel Merkle

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Marcel Friedrichs 1,2^{1,2}, Addie Jordon 1,2^{1,2}, Juri Kolčák 1,2^{1,2}, and Daniel Merkle 1,2,3^{1,2,3}

1^{1} Algorithmic Cheminformatics Group, Faculty of Technology, Bielefeld University, Germany

2^{2} Center for Biotechnology (CeBiTec), Bielefeld University, Germany

3^{3} Department of Mathematics and Computer Science (IMADA), University of Southern Denmark, Odense, Denmark

Abstract. Graph transformations model changing systems, with applications in software, biology and chemistry, among others. We introduce MolFoundry, a graph transformation framework, and present a workflow for observable analysis that tracks the dynamics of local patterns through rule composition. Analysing rule compositions avoids the need to enumerate a potentially infinite state space. Building on rule-algebraic stochastic rewriting, MolFoundry's kernel composes rules with nested application conditions, including missing-edge constraints. Given rules, rates and query patterns, the algorithms iteratively identify auxiliary pattern counts and search for closure. Using exact counting identities supplied by graph-family backends, successful searches yield closed ordinary differential equations for average counts or, with justified individual jumps, finite event models describing joint changes and rates. We evaluate conditional composition and automated discovery of auxiliary observables against published calculations and independent rule application. Applications to aldol addition, copolymerization and chlorination show how the framework yields quantitative predictions directly from molecular graph rules.

1 Introduction

Graph transformations are an established approach to modelling systems whose structures change. Applications range from software models and visual languages [18,12][18,12] to chemical reaction systems [1][1] and biological interaction networks [8][8]. Graphs represent entities and their relationships; local rules specify how these entities and relationships can be created, deleted or reconnected. A key strength is that this graphical description has rigorous mathematical semantics. In algebraic graph transformation, rules themselves can be composed, providing a formal connection between individual transformations and their combined effects [4,6][4,6].

Several tools make substantial parts of this framework available in practice. AGG supports modelling, execution and validation of graph transformation

M. Friedrichs et al.

systems [18]; GROOVE provides state-space exploration and model checking [12]. MOD supports molecular graph rewriting, reaction-network generation and rule composition [1], while the Kappa platform provides simulation and analysis of biochemical models [8]. Despite the range of graph transformation tools, not every theoretical capability is available as an automated analysis.

One particularly compelling capability is to infer quantitative behaviour directly from rules, their rates and a few query patterns. How does the count of each pattern change over time, on average? Which counts change together and which counts influence others? These count functions are called observables; expectations of their values, products and powers are their moments. Behr and collaborators developed a rule-algebraic calculus for their evolution and, through polynomial jump closure, for converting joint moment dynamics into equations for generating functions [3]. This permits the analysis of selected counts without enumerating every graph state, even when the rules generate a potentially infinite state space. Conditional composition theory [6], and its application to stochastic models in the life sciences [7], extend these foundations to rules and observables with structural conditions, such as requiring a connection to be absent (a missing-edge constraint).

Important steps toward executable analysis already exist. FRAGGER automates the expansion of graph rate equations and recursively introduces the counts needed to express their changes [10]; KaDE compiles Kappa rules into reaction-network ordinary differential equation (ODE) models with symmetry-based reductions [9]. Earlier Z3 prototypes address constrained overlaps for rule composition and commutator calculations [5]. These are substantial building blocks, but the published implementations do not combine conditional composition, automatic discovery of auxiliary observables, and extraction of their joint jumps and rates. FRAGGER identifies nested application conditions as future work [10, Section 4]. In a published molecular case study, a conditioned observable had to be replaced by an unconditioned one because the implementation could not represent its condition [7, Section 8.3.1].

Related reductions include stochastic lumping of rule-based models [11] and constrained lumping of existing ODE systems, as in CLUE [17]. Unlike reduction of an existing ODE system, our analysis discovers count dynamics directly from conditional graph rules, even when no finite reaction network is available.

Observable analysis repeatedly computes how each rule changes a selected pattern count. Conditional composition gives an expression for its instantaneous expected change [7]. New pattern counts in the resulting expression are analysed in turn, forming an iterative dependency-discovery process.

The need for auxiliary observables is already visible in a growing A/B chain. The two paths in Figure 1 both have zero occurrences of ABA, but appending A creates an ABA occurrence only for the path ending in AB. The change in the ABA count therefore depends on the AB ending count; the motif count alone cannot describe its own changes. This running example follows the analysis in Section 3 and later corresponds to a copolymer sequence.

Figure

Fig. 1. The paths w1=BABBw_1 = BABB and w2=BBABw_2 = BBAB both have zero ABA occurrences. Appending A leaves the upper count unchanged but creates one occurrence below (green), because only w2w_2 ends in AB (blue). This ending count is an auxiliary observable discovered by MolFoundry.

A successful search can yield a finite closed system of ODEs for expected counts [10], or a finite event model recording simultaneous count changes and rates. The latter retains fluctuations and dependencies beyond the means, but need not yield a finite expectation ODE. Polynomial expressions for average changes alone do not determine individual jumps. Neither kind of closure is guaranteed for arbitrary rules and queries [3, Section 6].

We present an executable workflow for observable analysis built on Mol-Foundry, combining multiplicity-preserving conditional composition, sound graph-family pruning, and shared searches for exact observable dynamics. MolFoundry's kernel computes conditional rule compositions, including missing-edge tests (NoEdge) and transport of nested application conditions. On top of this core, shared algorithms search for linear expectation closure or discover polynomial support and, with justified individual jumps, construct finite event models. Graph-family backends supply exact counting identities; the algorithms discover which auxiliary observables a query needs. The resulting guarantees are relative to these supplied identities and jump arguments, not to arbitrary graph families. Unfinished searches retain partial results and pending work.

We apply this workflow to chemistry, where structural conditions can change quantitative predictions. We automate the conditional compositions in the published aldol-addition case study [7] with the observable's missing-edge condition intact, derive sequence-count dynamics directly from atom-resolved copolymerization rules on chains of unbounded size, and analyse a stylised chlorination model in which a negative application condition (NAC)—a special case of nested conditions forbidding a pattern extension—prevents further substitution.

Section 2 states the mathematical requirements, Section 3 describes the workflow, and Section 4 evaluates composition, query reuse and agreement with independent calculations. The mathematical appendices and material guide give counting arguments and executable inputs.