---
title: 'Walnut: Theorem Prover & Diverse Applications'
url: https://www.emergentmind.com/topics/walnut
type: topic
---

# Walnut: Theorem Prover & Diverse Applications

to=arxiv_search.query  天天中彩票为什么?  乐亚რგuments  as_json=true  ವಿಷಯ={"query":"Walnut arXiv theorem prover automatic sequences software", "max_results": 5}
to=arxiv_search.search  北京赛车的ીക്കം 不中反json=true  arguments={"query":"Walnut theorem prover automatic sequences", "max_results": 10, "sort_by":"relevance"}
to=arxiv_search 《凤凰大参考json=true  arguments={"query":"Walnut theorem prover automatic sequences", "max_results": 10}
Walnut is used in recent arXiv literature for several unrelated research objects. The best-known technical sense is an open-source, automata-based theorem prover for deciding first-order statements about automatic sequences; other uses include a low-trust trigger-action platform, a semi-weakly supervised learning benchmark for natural language understanding, a UAV-and-machine-learning workflow for walnut water-stress mapping, and the “walnut” structure identified in the Japanese production network [1603.06017][2009.12447][2108.12603][2401.01375][1808.10090].

## 1. Walnut as an automata-based theorem prover

In combinatorics on words and automata theory, Walnut is an open-source Java package that implements a mechanical decision procedure for a large fragment of first-order logic over the natural numbers enriched with one or more automatic sequences [1603.06017]. Its core mathematical object is the $k$-automatic sequence: a sequence $(a_n)_{n\ge0}$ over a finite alphabet $\Delta$ is $k$-automatic if there exists a deterministic finite automaton with output (DFAO)
$$
M=(Q,\Sigma_k,\delta,q_0,\Delta,\tau)
$$
such that whenever the base-$k$ expansion of $n$ is $(d_1d_2\cdots d_r)_k$, the run of $M$ on $d_1d_2\cdots d_r$ ends in a state $q$ with $\tau(q)=a_n$ [2201.05954].

The logical fragment supported by Walnut is the first-order theory of $(\mathbb{N};+,0,1,\le)$ extended by indexed predicates of the form $W[x]=a$ [2201.05954]. In the broader presentation of the system, the decidable structure is described as first-order logic over $(\mathbb{N}; +, <)$ enriched with automatic sequences, arithmetic expressions built from $+, -, \times c, \div c$ for constant $c$, comparisons, indexing into automatic words, and previously defined automata called as predicates [1603.06017]. Built-in numeration systems include binary MSD/LSD and Fibonacci, and users can define new number systems, new automatic words, or import arbitrary automata [1603.06017].

This formulation makes Walnut a theorem prover in a precise automata-theoretic sense: it does not reason by symbolic proof search in the style of interactive proof assistants, but instead compiles logical formulas to finite automata and decides them by standard automaton operations [2201.05954].

## 2. Decision procedure, syntax, and command language

Walnut proceeds structurally on formulas. A query is parsed into an abstract syntax tree; atomic predicates such as $x+y=z$ or $W[x]=a$ are converted into small automata; conjunction and disjunction are handled by synchronous product and union; negation is handled by complement; existential quantification is implemented by projection; and universal quantification is reduced to the negation of an existential statement, so validity and counterexample search reduce to emptiness checking [2201.05954]. In the formal account of the software architecture, conjunction/disjunction correspond to intersection/union, negation to complementation after totalization, and existential quantification to delete-tape projection followed by determinization, minimization, and recovery of zero-representations [1603.06017].

Walnut’s input language is close to mathematical notation. In the syntax summarized for combinatorics-on-words applications, `A` denotes $\forall$, `E` denotes $\exists$, `&` denotes $\wedge$, `|` denotes $\vee$, `~` denotes $\neg$, `=>` denotes $\implies$, and indexing is written in the form `W[i] = @a` [2201.05954]. The REPL-level command set includes `eval`, `def`, `reg`, `macro`, and `load`; outputs can be exported as `.gv`, `.txt`, `_log.txt`, `_detailed_log.txt`, and optionally `.mpl` [1603.06017].

A representative Walnut session for factor comparison and Ziv–Lempel factorization uses definitions of the form [2403.15215]:
```text
def xfactoreq "?msd_k At t<n => X[i+t]=X[j+t]";
def xzfactor "?msd_k (Aj j<i => ~$xfactoreq(i,j,n))
                 & (At t<n => (El l<i => $xfactoreq(i,l,t)))";
eval xzcheck "?msd_k Ai An $xzgoodrep(i,n) => $xzfactor(i,n)";
```

For closed formulas Walnut reports `TRUE` or `FALSE`; when free variables remain, it returns the minimized automaton accepting exactly the tuples that satisfy the formula [1603.06017]. The design philosophy emphasized in later presentations is clarity of specification, reuse of off-the-shelf automata-theoretic algorithms, and extensibility via morphisms, images, and built-in operations [2201.05954].

## 3. Mathematical applications of Walnut

Walnut has been used extensively in combinatorics on words. In work on partial words, it was used both to prove new results and to reprove old results on avoiding squares and cubes. The reported results include an infinite binary partial word with holes avoiding all squares of order $\ge 4$, an infinite partial word avoiding squares of order $\ge 7$ and antisquares of order $\ge 3$, tables of extremal partial words with one hole containing bounded numbers of distinct squares and antisquares, and machine-checked proofs for hole-sparsity constructions avoiding non-trivial squares or cubes [2201.05954].

In studies of factorization of automatic sequences, Walnut was used to verify Ziv–Lempel and Crochemore factorizations for Fibonacci, Thue–Morse, period-doubling, Rudin–Shapiro, paper-folding, and Mephisto-Waltz words. The method is explicit: one defines predicates for factor equality and for the factorization condition, guesses a regular expression for the position-length pairs $(i_m,n_m)$, and asks Walnut to certify that the guessed regular language implies the desired factorization property [2403.15215]. A central limitation is stated plainly: Walnut does not discover the factorization on its own; candidate discovery remains manual [2403.15215].

The theorem prover has also been extended beyond ordinary base-$k$ arithmetic. By adding base $(-k)$ representations, Walnut can quantify over $\mathbb{Z}$ rather than $\mathbb{N}$, thereby supporting bi-infinite automatic sequences. The extension introduces the modes `?msd_neg_k` and `?lsd_neg_k` together with the commands `split`, `rsplit`, and `join`, and it was used to reprove and strengthen results of Shevelev and to reprove Shur’s result on bi-infinite binary words [2208.06025].

Further developments expanded Walnut’s reach to transductions of automatic sequences, generalized numeration systems, additive complexity, congruence properties, OEIS problems, and combinatorial game theory. Dekking-style transduction was implemented directly in Walnut and applied to problems including representations of $n!$ as a sum of three squares, overlap-free Dyck words, and iterated running sums of Thue–Morse [2303.15203]. Additive complexity computations were expressed via synchronized prefix counts, factor counts, additive-equivalence predicates, and the semigroup-trick algorithm, yielding exact DFAO descriptions for examples such as the ternary Thue–Morse word and the Tribonacci word [2410.02409]. Other work used Walnut to resolve open problems from the OEIS, to verify congruence properties of Catalan and Motzkin numbers modulo prime powers, to check properties of Zeckendorf and Chung–Graham representations, and to certify P-position characterizations in variants of Wythoff’s game [2503.04122][2110.06244][2507.06162][2512.11601].

## 4. Complexity, performance, and limitations

The algorithmic cost profile of Walnut is governed by standard automata operations. Cross-product of an $m$-state and an $n$-state automaton produces $O(m\cdot n)$ states; determinization can blow up exponentially in the number of states; minimization of a $d$-state DFA can be done in $O(d \log d)$ time via Valmari’s algorithm; and the overall translation from a formula of quantifier depth $Q$ and subformula size $S$ may be non-elementary in $Q$, matching known lower bounds for Presburger arithmetic [1603.06017].

Empirical reports in the literature reflect both tractability and blow-up. In the partial-word study, the automaton for avoiding squares of order $\ge 4$ in the full-word case had 217 states and built in 10 ms, while the analogous partial-word case had 229 states and took 24 ms [2201.05954]. In the factorization study, final emptiness checks ran in a fraction of a second to a few seconds on a standard laptop, and the resulting automata had at most a few hundred states [2403.15215]. In work on Wythoff variants, however, the absorbing check for $W^3$ exceeded $10^5$ states [2512.11601].

The limitations are correspondingly concrete. Some morphic constructions lead to automata of enormous size, on the order of hundreds of gigabytes, and can exceed practical memory limits [2201.05954]. Mixed MSD/LSD quantification is only partially supported [1603.06017]. Candidate discovery in factorization problems remains manual [2403.15215]. Parameterized theorems in $\ell$ for terminal-position Wythoff variants cannot yet be proved uniformly; $\ell$ must be fixed [2512.11601]. Suggested extensions include native support for holes, specialized algorithms for tree-like or hierarchical morphisms, symbolic or BDD-based representations, and parallelized or on-the-fly emptiness and projection procedures [2201.05954].

## 5. Walnut in systems security and machine learning

A distinct systems paper uses Walnut as the name of a low-trust trigger-action platform in the spirit of IFTTT [2009.12447]. Its architecture splits the platform across two administrative domains, each hosting one general-purpose machine and three TEEs from different vendors. Applets contain a trigger specification, an action specification, and `filterCode`; setup uses ECIES encryption and XOR-based secret-sharing of setup-time action-input blocks; trigger polling occurs every 15 minutes; action generation uses either Yao’s generic two-party secure computation protocol or a custom `string_sub` routine specialized to placeholder substitution; and action execution is accepted only if the required signatures verify [2009.12447].

The stated security goals are confidentiality of user data and correctness of computation under both passive and active adversary models [2009.12447]. The evaluation reports, relative to a non-secure baseline, platform-side CPU overhead of $3.6\times$ and network overhead of $4.3\times$ for string-substitution applets, with worst-case overheads of $54\times$ CPU and $1883\times$ network when Yao’s protocol is needed for custom code [2009.12447]. The same paper states that approximately $98\%$ of IFTTT applets fall into the cheap string-substitution category and that the prototype was open-sourced and tested on 30 applets [2009.12447].

In machine learning, WALNUT denotes the “semi-WeAkly supervised Learning for Natural language Understanding Testbed,” a benchmark for weak supervision in NLU [2108.12603]. It contains eight tasks, partitioned into document-level tasks and token-level tasks, with each task providing a small clean set and a large weakly labeled set generated by multiple real-world weak sources [2108.12603]. Baselines include clean-only training, weak-only training, clean-plus-weak training, and advanced semi-weak methods such as GLC, MetaWN, and MLC; evaluated encoders include BiLSTM with 50-dim GloVe, DistilBERT-base, BERT-base, BERT-large, RoBERTa-base, and RoBERTa-large [2108.12603]. The reported average micro-F1 values across the eight tasks are $64.5\%$ for clean only, $63.9\%$ for weak only with majority voting, $64.2\%$ for weak only with Snorkel, $65.8\%$ for clean-plus-weak with majority voting, $66.3\%$ for clean-plus-weak with Snorkel, $66.9\%$ for GLC, $62.8\%$ for MetaWN, and $81.8\%$ for the full-clean ceiling [2108.12603]. The benchmark highlights that weak supervision benefits smaller models more than larger pre-trained encoders, and that document-level tasks tend to benefit more than token-level NER tasks [2108.12603].

## 6. Agricultural and network-science usages

In agricultural remote sensing, “walnut” refers literally to walnut orchards. A UAV-based workflow for mapping walnut water stress integrates multispectral and thermal imagery with weather data to predict stem water potential (SWP) via Random Forest models [2401.01375]. Over the 2017 and 2018 growing seasons, five midday flights were conducted above a commercial walnut block near UC Davis using a DJI Matrice 100 carrying a MicaSense RedEdge camera with seven spectral bands: blue, green, panchromatic, red, red-edge, near-infrared, and long-wave infrared. Flights at 120 m yielded an 8 cm ground sampling distance; radiometric consistency used calibrated reflectance-panel images; georeferencing accuracy of less than 30 cm used five ground control points; and orthomosaics were generated in Pix4DMapper Pro and co-registered in QGIS [2401.01375].

Canopy pixels were isolated with a DSM mask and the Normalized Excess Green index
$$
\mathrm{NExG} = \frac{2\cdot \mathrm{Green} - \mathrm{Red} - \mathrm{Blue}}{\mathrm{Green} + \mathrm{Red} + \mathrm{Blue}},
$$
after which NDVI, NDRE, and PSRI were computed [2401.01375]. The Random Forest regression used the feature vector
$$
x_{ij} = [\mathrm{Thermal}_{ij}, \mathrm{NDVI}_{ij}, \mathrm{NDRE}_{ij}, \mathrm{PSRI}_{ij}, T_j, \mathrm{VPD}_j, u_j]
$$
and the estimator
$$
\hat{\mathrm{SWP}}_{ij} = \frac{1}{M}\sum_{m=1}^M T_m(x_{ij}).
$$
The dataset, excluding the first low-quality flight, comprised 200 samples split $80\%/10\%/10\%$ into training, validation, and test sets with 10-fold cross-validation [2401.01375]. The abstract reports $R^2$ of 0.63 and MAE of 0.80 bars; the detailed summary reports aggregated $R^2$ of 0.65 $(\pm 0.15)$ and MAE of roughly 0.80 bars, with the full classification model achieving $85\%$ accuracy and the NoRedEdge variant $80\%$ accuracy [2401.01375].

In network science, the “walnut structure” is a structural description of the Japanese production network [1808.10090]. The giant weakly connected component is decomposed as
$$
\mathrm{GWCC} = \mathrm{GSCC} + \mathrm{IN} + \mathrm{OUT} + \mathrm{TE},
$$
with component sizes reported from the July 2016 snapshot as $|\mathrm{GSCC}| = 530\,174$ firms, $|\mathrm{IN}| = 219\,927$, $|\mathrm{OUT}| = 278\,880$, and $|\mathrm{TE}| = 37\,056$ [1808.10090]. The term “walnut” is used because the GSCC forms a central “nut” tightly surrounded by IN and OUT shells, rather than the loose wings of a textbook bow-tie; $96.8\%$ of all IN nodes are exactly one step upstream of the GSCC, and $95.7\%$ of all OUT nodes are exactly one step downstream [1808.10090]. Hierarchical community detection with Infomap found 209 communities at level 1 and 65,303 communities at level 2, with $93.64\%$ of firms residing in irreducible communities at the second level [1808.10090]. The same study reports that only approximately $20.9\%$ of unweighted directed links lie within the same sector, whereas approximately $63.3\%$ lie inside network-detected communities; with estimated sales flows, the corresponding figures are approximately $14.3\%$ within sectors and approximately $55.9\%$ within communities [1808.10090]. This finding is presented as questioning the validity and accuracy of conventional input-output analysis when firms in the same sectors are assumed to be highly connected [1808.10090].

Source: https://www.emergentmind.com/topics/walnut