The Ackermann function is a famous total recursive binary function on
the natural numbers.  It is the archetypal example of such a
function that is not primitive recursive, in the sense of classical
recursion theory.  However, and in seeming contradiction, there are
generalized notions of total recursion, for which the Ackermann
function is in fact primitive recursive, and often featured as a
witness for the additional power gained by the generalization.  Here,
we investigate techniques for finding and analyzing the primitive form
of complicated recursive functions, namely also Knuth's and Conway's
arrow notations, in particular by recursion abstraction, in a
framework of functional program transformation.

§ INTRODUCTION

The Ackermann function is a famous total binary
function on the natural numbers, given by the recursive equations:

\begin{equation*}
\begin{array}{rcl@{\qquad}r}
A(0, n) &=& n + 1
\\
A(m, 0) &=& A(m - 1, 1) & (m > 0)
\\
A(m, n) &=& A\bigl(m - 1, A(m, n - 1)\bigr) & (m, n > 0)
\end{array}
\end{equation*}

It is not a particularly useful function in practice; its fame (and
ubiquitous appearance in undergraduate computer science curricula)
stems from the fact that it is one of the simplest examples of a
total, recursive (that is, recursively computable) function which is
not primitive recursive.  The class of primitive recursive
functions is defined inductively, characteristically involving a
recursion operator that, simply speaking, allows the value of a
function at $n$ depend on its value at $n - 1$, without explicit self-reference.

Intuitively (and provably), the doubly nested self-reference of the
Ackermann function in the third equation refuses to be adapted to the
primitive recursion scheme.  But one may find seemingly contradictory
statements: the notion of primitive recursion is relative to its
underlying datatype $\mathbb{N}$; the Ackermann function does
have a representation in terms of analogous recursion operators for
suitable, more powerful datatypes [6, 2].  A
systematic introduction to recursion operators on
lists [3] gives the Ackermann function (disguised as a
list function) as a high-end example, but does not discuss the
generalization to related functions.  Here, we start off where they
concluded.  The purpose of the present article is threefold:

* Recall from [3] how to obtain
a “primitive” representation of Ackermann's and related functions by
means of systematic recursion abstraction in a higher-order
functional programming language.
* Pinpoint how exactly these
representations are “cheating” with respect to the original,
first-order definition of primitive recursion.
* Generalize
the approach to (apparently) even more complicated recursive

We begin by summarizing formal details about primitive recursion in
mathematical theory and in functional programming.  The expert reader
is welcome to safely skip the next, preliminary section.  The
remainder of the article is about three concrete examples, in increasing
order of logical complexity: the Ackermann function (archetypal),
Knuth's up-arrows (slightly more powerful), Conway's chained arrows
(significantly more powerful).  They form a well-known hierarchy of
operators for the arithmetics of “insanely large” numbers.

Even the non-expert reader might enjoy a quick glance ahead at Figures
<ref> and <ref> on page fig:trad, where
the classical and primitive definition forms are contrasted in
synopsis.  With a little contemplation, all elements of the latter,
except the  operators, can be found verbatim in the former.  The
remainder of this article is a thorough exploration of the formal
details that constitute their respective equivalence.

The program code scattered throughout this article is a valid literate
Haskell program.  It makes use of standard Haskell'98 features only,
with the exception of some  in meta-level analyses.
Note that, for better fit with the mathematical notation, the
first-fit rule of Haskell pattern matching is shunned; all overlapped
patterns are explicitly guarded.

§ PRIMITIVE RECURSION

§.§ Primitive Recursion in Mathematics

The conventional definition of the class of primitive recursive
functions is inductive.  It contains the nullary zero function
and the unary successor function, and the projections, is
closed under composition and under a certain recursion operator:

Let $e$ and $g$ be $k$-ary and $(k+2)$-ary primitive recursive
functions, respectively.  Then the unique $(k+1)$-ary function $h$
given by the recursive equations

\begin{equation*}
\begin{array}{rcl@{\qquad}r}
h(x_1, \dots, x_k; 0) &=& e(x_1, \dots, x_k)
\\
h(x_1, \dots, x_k; n) &=& g\bigl(x_1, \dots, x_k; n - 1, h(x_1, \dots, x_k; n - 1)\bigr) & (n > 0)
\end{array}
\end{equation*}

is also primitive recursive.  Then the self-referential definition of
$h$ can be replaced equivalently by a “primitive” one, specifying
$e$ and $g$ instead.  It has been shown by Ackermann that a precursor
to the function now named after him is not of this form.
Double recursion [7] has been introduced ad-hoc for
Ackermann's and related functions, but obviously a nesting depth of
two is no natural complexity limit—why not have triple recursion, and
so forth?  Less arbitrary limits are given by type systems that allow
recursive computations on other datatypes than just natural numbers;
see below.

§.§ Primitive Recursion in Functional Programming

The algebraic approach to functional
programming [5, 1] generalizes the notion of a
recursion operator to arbitrary algebraic datatypes (and with some
effort, beyond).  In a functional programming context, one can do away
with the auxiliary arguments $x_1, \dots, x_k$ to the generating
functions $e$ and $g$, by having them implicitly as free variables in the
defining expression.  One can also do away with the $(k+1)$-th
argument without losing essential power [4], thus
arriving at a scheme called variously structural recursion,
iteration, fold or catamorphism.

In the base case of the natural numbers (represented here by the
Haskell datatype , tacitly excluding negative numbers and
), the operator is:
[3]foldn [10]
[10]g [13]
[13]e [16]

[3]foldn [10]
[10]g [13]
[13]e [16]
[30]g (foldn g e (n-1))[E]
This form, as well as the constructor operations zero and
succ, can be deduced from the category-theoretic representation
of the natural numbers as the initial algebra of a certain functor.
We do not repeat the details here, but one consequence is highly
relevant: Fold operators have the nice universal property of
uniqueness.  On one hand, we can of course retrieve the
preceding definition, where the generated function is named h:

From  we can conclude
[3]h [6]

[3]h [6]
[21]g (h (n-1))[E]
But, on the other hand, the converse does also hold: From
[3]h [6]

[3]h [6]
[21]g (h (n-1))[E]
we may deduce that necessarily .

This will become our tool of recursion abstraction in the following
sections.  As pointed out in [3] for the Ackermann
example, the characteristic feature of “morally primitive” recursive
functions is that this abstraction needs to applied more than once.

The resulting recursive functions do not look particular powerful at
first glance: mathematically,  is simply $g^n(e)$.  Their
hidden power comes from the polymorphic nature of the fold operator,
which can define functions from the natural numbers to arbitrary
underlying datatypes.
[3]𝐭𝐲𝐩𝐞 FoldN a=(a→a)→a→Integer→a[E]

[3]foldn::FoldN a[E]

The fold operator for lists is arguably the most popular one; see
[3].  This is not only due to the fact that lists are
the workhorse of datatypes: List folding is both reasonably simple
regarding type and universal properties, and gives to nontrivial,
useful recursive algorithms already from very simple generator
[3]foldr g e [1.5mu 1.5mu][23]

[3]foldr g e (a:xs)[23]
[26]g a (foldr g e xs)[E]
The type scheme for list folding is
[3]𝐭𝐲𝐩𝐞 FoldR a b=(a→b→b)→b→[1.5mu a1.5mu]→b[E]

[3]foldr::FoldR a b[E]
where we now have two type parameters; namely  for the list
elements to be consumed, and  for the underlying datatype in which
to perform the computation.

The associated universal property is that for a recursive function
on lists, the equations
[3]h [1.5mu 1.5mu][14]

[3]h (a:xs)[15]
[19]g a (h xs)[E]
hold if and only if .

The trick behind apparently primitive representations of Ackermann and
friends is to instantiate the fold type schemes with an underlying datatype that is strictly more
powerful than the natural numbers, that is, that cannot be
Gödel-encoded and -decoded by primitive recursive functions in the
original sense.

Consider a type system that has some algebraic types.  Then the class
of primitive recursive functions relative to that type system
is defined inductively as containing some elementary functions, and
being closed under composition and the fold operators for all
algebraic datatypes, instantiated with all valid types.

The classical definition can be retrieved as the special case of the
type system whose only datatype is $\mathbb{N}$, and whose function
types are all of the first-order form $\mathbb{N}^k \to \mathbb{N}$.
The programme of the present article is to consider functions that are not
primitive recursive in that classical sense, and to study the
derivations of their respective primitive forms in a more powerful
type system, namely one with higher-order function types, as usual in
functional programming languages.

Our chief interest lies in the program transformation techniques necessary
to take a self-referential definition, in terms of generally
recursive equations, to a primitive definition, that is an
expression without self-references, and composed only of legal building
blocks for primitive recursive functions.

§.§ Elimination of Recursion

The skeptical reader might wonder what qualifies the fold operators as
particularly primitive, seeing that their definitions make blatant use of
self-reference.  But that is an artifact of the way algebraic
datatypes are commonly defined.  An alternative definition technique,
namely Church encoding, does not have this property.  A
Church-encoded version of the natural numbers is the following
non-recursive type definition:

[3]𝐭𝐲𝐩𝐞 Nat=∀ a.(a→a)→a→a[E]

It allows the construction of numbers by the usual operations, by
strategic deferral of their respective interpretations
and :

[3]zero s z=z[E]

[3]succ n s z=s (n s z)[E]

A trivial coercion to standard Haskell numbers can be given by
providing the obvious interpretations.

[3]toInteger n=n (+1) 0[E]

But, less trivially, every Church-encoded number implements the action
of the fold operator on itself, by substituting  for  and
for , respectively, which can thus be defined without
self-reference as

[3]foldn' g e n=n g e[E]
and is easily seen to be equivalent to the original:
[3]foldn' g e≡foldn g e∘toInteger[E]

For a general discussion of this construction for arbitrary algebraic
datatype signatures, and its equivalence to the initial algebra
approach, see [8].

\begin{equation*}
\fbox{$
\begin{array}{rcl@{\qquad}r}
A(0, n) &=& n + 1
\\
A(m, 0) &=& A(m - 1, 1) & (m > 0)
\\
A(m, n) &=& A(m - 1, A(m, n - 1)) & (m, n > 0)
\\[1em]
a \uparrow^0 b &=& a\, b
\\
a \uparrow^n 0 &=& 1
\\
a \uparrow^n b &=& a \uparrow^{n-1} (a \uparrow^n (b - 1)) & (n, b > 0)
\\[1em]
\langle p \to q\rangle &=& (p+1)^{(q+1)}
\\
\langle X \to p \to 0\rangle &=& \langle X \to p\rangle
\\
\langle X \to 0 \to q\rangle &=& \langle X \to 0\rangle
\\
\langle X \to p \to q\rangle &=& \langle X \to (\langle X \to (p - 1) \to q\rangle - 1) \to (q - 1)\rangle
& (p, q > 0)
\end{array}$}
\end{equation*}

Exercise—Ackermann, Knuth and Conway in traditional appearance

[30]foldn (λf→foldn [51]
[51]f [71]
[71](f 1)[80]
[80]) [100]

[30]foldn (λf→foldn [51]
[51]f [71]

[13]foldr (λo k→[30]
[30]foldn (λf→foldn [51]
[51](f∘(- 1)) [71]
[71](k 0 o)[80]
[80]) [83]
[83](λp→k p o)) [100]

[5]𝐰𝐡𝐞𝐫𝐞 cpow q p=(p+1)(q+1)[E]

Solution—Ackermann, Knuth and Conway looking like a bunch of primitives

§ THE ACKERMANN FUNCTION

§.§ Derivation

We start with the Haskell version of the original self-referential definition
[3]ack_0 [9]
[9]0 [12]

[3]ack_0 [9]
[9]m [12]
[35]ack_0 (m-1) 1[E]

[3]ack_0 [9]
[9]m [12]
[35]ack_0 (m-1) (ack_0 m (n-1))[E]
and proceed by successive application of elementary transformation
steps.  Each new version is indexed differently, such that all can
coexist in a single literate Haskell source file for this whole article.

In a first transformation step, we exploit currying to eliminate the
second function argument  and thus unify the second and third
equation in an auxiliary function .
[3]ack_1 [9]

[3]ack_1 [9]

[5]𝐰𝐡𝐞𝐫𝐞 [13]
[13]aux [18]
[32]ack_1 (m-1) 1[E]

[13]aux [18]
[32]ack_1 (m-1) (ack_1a m (n-1))[E]

We factor out the common term  by beta expansion to an
argument .  What seems like a simple matter of abbreviation here
will prove a very useful preparation step later.
[3]ack_1a [10]

[3]ack_1a [10]
[24]aux (ack_1a (m-1))[E]

[5]𝐰𝐡𝐞𝐫𝐞 [12]
[12]aux [17]
[17]f [20]
[34]f 1[E]

[12]aux [17]
[17]f [20]
[34]f (ack_1a m (n-1))[E]

The single most tricky point is to get rid of the back-reference from
to .  Note that  is only ever applied to , hence we may substitute[In case of doubt about the
validity of this slightly simplified argument, see
section <ref> for details.]
[3]ack m≡aux (ack (m-1))≡aux f[E]
and obtain:
[3]ack_1b [10]

[3]ack_1b [10]
[24]aux (ack_1b (m-1))[E]

[5]𝐰𝐡𝐞𝐫𝐞 [12]
[12]aux [17]
[17]f [20]
[34]f 1[E]

[12]aux [17]
[17]f [20]
[34]f (aux f (n-1))[E]

Now we have  in a form generated by the fold operator from a
function  whose definition is independent from .  We may invoke the
universal property and conclude:
[3]ack_2=foldn aux (+1)[E]

[5]𝐰𝐡𝐞𝐫𝐞 [12]
[12]aux [17]
[17]f [20]
[34]f [37]

[12]aux [17]
[17]f [20]
[34]f [37]
[37](aux f (n-1))[E]

It remains to be established that the self-referential definition of
the generator  can be reduced to a primitive form.  As it
happens, it is already of the right shape.
[3]ack_3=foldn aux (+1)[E]

[5]𝐰𝐡𝐞𝐫𝐞 [12]
[12]aux f=foldn f (f 1)[E]

So, in summary, we have the Ackermann function given by an entirely
non-self-referential expression that invokes two nested instances of
the fold operator.
[3]ack_4=foldn (λf→foldn f (f 1)) (+1)[E]

§.§ Verification

Since the final version of the Ackermann function admittedly looks
very different from the original one, it is instructive to expand it
back and demonstrate the inductive equivalence to the original
recursive equations.
As the base case for  we have
[3]ack_4 0 n[13]
[17]foldn (λf→foldn f (f 1)) (+1) 0 n[E]

[17](+1) n[E]

and as the inductive case we have
[3]ack_4 m|m>0[19]
[49]foldn (λf→foldn f (f 1)) (+1) [88]

[23](λf→foldn f (f 1)) ([49]
[49]foldn (λf→foldn f (f 1)) (+1) [85]

[23](λf→foldn f (f 1)) (ack_4 [85]

[23]foldn (ack_4 (m-1)) (ack_4 (m-1) 1)[E]
which cannot be unfolded yet.  Proceeding to the second argument,
we have the base case
[3]ack_4 m 0[13]
[17]foldn (ack_4 (m-1)) ([41]
[41]ack_4 (m-1) 1) 0[E]

[41]ack_4 (m-1) 1[E]
and the inductive case
[3]ack_4 m n|n>0[21]
[41]foldn (ack_4 (m-1)) (ack_4 (m-1) 1) [83]

[25]ack_4 (m-1) ([41]
[41]foldn (ack_4 (m-1)) (ack_4 (m-1) 1) [80]

[25]ack_4 (m-1) ([41]
[41]ack_4 m [80]
by back-substitution.   $\Box$

§.§ Analysis

So, in a sense, the Ackermann function is primitive after all!  As
discussed above, the polymorphic fold operator glosses over the fact
that underlying datatypes of different, incommensurable power are used
here.  To make things more explicit, consider monomorphic instances of
[3]foldn_1::FoldN Integer[E]

[3]foldn_2::FoldN (Integer→Integer)[E]

Using these, we can make the different roles explicit:
[3]ack_5=foldn_2 (λf→foldn_1 f (f 1)) (+1)[E]
Contradiction is avoided by the fact that the higher-order datatype
underlying the outer instance cannot be converted to and from the
traditional first-order datatype underlying the inner one by means of
primitive recursive conversion functions.

§ KNUTH'S UP-ARROWS

A natural next candidate function to investigate is Knuth's up-arrow,
which is known to have quite similar but mildly more flexible behavior
than the Ackermann function.  The usual recursive definition is, for $a, b \geq 0; n > 0$:

\begin{equation*}
\begin{array}{rcl@{\qquad}r}
a \uparrow^1 b &=& a^b
\\
a \uparrow^n 0 &=& 1
\\
a \uparrow^n b &=& a \uparrow^{n-1} \bigl(a \uparrow^n (b - 1)\bigr) & (n > 1; b > 0)
\end{array}
\end{equation*}

This can be canonically extended to $n = 0$:

\begin{equation*}
\begin{array}{rcl@{\qquad}r}
a \uparrow^0 b &=& a\, b
\\
a \uparrow^n 0 &=& 1 & (n > 0)
\\
a \uparrow^n b &=& a \uparrow^{n-1} \bigl(a \uparrow^n (b - 1)\bigr) & (n,b > 0)
\end{array}
\end{equation*}

which is also a neat case of consistent abuse of notation, seeing that

\begin{equation*}
a \uparrow^n b = a \underbrace{\uparrow\cdots\uparrow}_n b
\end{equation*}

§.§ Derivation

This definition translates straightforwardly to Haskell:
[3]knuth_0 [11]
[11]a [14]
[14]0 [17]

[3]knuth_0 [11]
[11]a [14]
[14]n [17]

[3]knuth_0 [11]
[11]a [14]
[14]n [17]
[41]knuth_0 a (n-1) (knuth_0 a n (b-1))[E]
In analogy to the Ackermann example, we curry argument .
[3]knuth_1 [11]
[11]a [14]

[3]knuth_1 [11]
[11]a [14]

[5]𝐰𝐡𝐞𝐫𝐞 [12]
[12]aux [17]

[12]aux [17]
[31]knuth_1 a (n-1) (knuth_1 a n (b-1))[E]

If we had tried this example first, we would probably have gotten
stuck at this point!  But following the procedure for the Ackermann
function, we beta-expand the recursive subterm , even
if there is only one occurrence, and the step does not simplify
anything at first glance.
[3]knuth_1a [12]
[12]a [15]

[3]knuth_1a [12]
[12]a [15]
[29]aux (knuth_1a a (n-1))[E]

[5]𝐰𝐡𝐞𝐫𝐞 [12]
[12]aux [17]
[17]f [20]

[12]aux [17]
[17]f [20]
[34]f (knuth_1a a n (b-1))[E]
We find that, in the context of the last equation, we can again substitute
[3]knuth a n≡aux (knuth a (n-1))≡aux f[E]
and arrive at:
[3]knuth_1b [12]
[12]a [15]

[3]knuth_1b [12]
[12]a [15]
[29]aux (knuth_1b a (n-1))[E]

[5]𝐰𝐡𝐞𝐫𝐞 [12]
[12]aux [17]
[17]f [20]

[12]aux [17]
[17]f [20]
[34]f (aux f (b-1))[E]

Now we may invoke the universal property of the fold operator to
abstract from the outer recursion first, as in the previous example.
[3]knuth_2a a=foldn aux (a*)[E]

[5]𝐰𝐡𝐞𝐫𝐞 [12]
[12]aux [17]
[17]f [20]

[12]aux [17]
[17]f [20]
[34]f (aux f (b-1))[E]
Or, alternatively, we may abstract from the inner recursion first.
[3]knuth_2b a 0[24]

[3]knuth_2b a n|n>0[24]
[27](λf→foldn f 1) (knuth_2b a (n-1))[E]
Either way, double recursion abstraction leads to:
[3]knuth_3 a=foldn (λf→foldn f 1) (a*)[E]
For the friends of point-free humor this is:
[3]knuth_4=foldn (λf→foldn f 1)∘(*)[E]

Visual type inference tells us that the nesting pattern is the same as
for the Ackermann function, a first-order instance of fold nested
within a second-order instance.
[3]knuth_5=foldn_2 (λf→foldn_1 f 1)∘(*)[E]

§.§ Verification

Although the mode of derivation has paralleled the, already verified,
Ackermann function quite closely, it might be assuring to repeat the
verification process for Knuth's arrows.  As the base case for  we
[3]knuth_3 a 0 b[17]
[21]foldn (λf→foldn f 1) (a*) 0 b[E]

[21](a*) b[E]

and as the inductive case we have:
[3]knuth_3 a n|n>0[23]
[49]foldn (λf→foldn f 1) (a*) [84]

[27](λf→foldn f 1) ([49]
[49]foldn (λf→foldn f 1) (a*) [81]

[27](λf→foldn f 1) ([49]
[49]knuth_3 a [81]

[27]foldn (knuth_3 a (n-1)) 1[E]
As the base case for  we have
[3]knuth_3 a n 0[17]
[21]foldn (knuth_3 a (n-1)) 1 0[E]

and as the inductive case we have:
[3]knuth_3 a n b|b>0[25]
[49]foldn (knuth_3 a (n-1)) 1 [80]

[29]knuth_3 a (n-1) ([49]
[49]foldn (knuth_3 a (n-1)) 1 [77]

[29]knuth_3 a (n-1) ([49]
[49]knuth_3 a n [77]

§ CONWAY'S CHAINED ARROWS

Knuth's up-arrow notation was conceived as an iterative generalization of
the step from addition to multiplication and from there to
exponentiation, remaining in the realm of binary operators.  Conway's
chained arrow notation releases the latter restriction to encode even
huger numbers.  It defines a single operator on a list of arbitrarily
many numbers, traditionally called “chains” and written with interspersed arrows (hence
the name).  A typical self-referential definition is the following
system of equations, where $p, q$ are numbers and $X$ is a nonempty

\begin{equation*}
\begin{array}{rcl@{\qquad}r}
\langle p\rangle &=& p
\\
\langle p \to q\rangle &=& p^q
\\
\langle X \to p \to 1\rangle &=& \langle X \to p\rangle
\\
\langle X \to 1 \to q\rangle &=& \langle X \to 1\rangle
\\
\langle X \to p \to q\rangle &=& \bigl\langle X \to \langle X \to (p - 1) \to q\rangle \to (q - 1)\bigr\rangle
& (p, q > 1)
\\
\multicolumn{4}{l}{\qquad\textrm{with the canonical extension}}
\\
\langle\,\rangle &=& 1
\end{array}
\end{equation*}

We have added angled brackets around chains to emphasize the relevance
of bracketing: since a chain denotes a number, chains may be nested
(as in the last equation); but unlike for many other arithmetic
operators, a chain of more than two elements is not merely an
abbreviation for the nested iteration of a binary operator $\to$.  The
full situation is complicated: even though generally $\langle o \to p
\to q\rangle$ is different from both $\langle\langle o \to p \rangle
\to q \rangle$ and $\langle o \to \langle p \to q \rangle \rangle$,
this does not imply that the overall operation cannot be
expressed by a fold operator acting binarily on the list of
numbers—that will be exactly our next move.

§.§ Derivation

The above equations, read left-to-right, specify a total evaluation
function.  It can be translated to a Haskell function on lists of
strictly positive numbers
[3]conway_0 [1.5mu 1.5mu][46]

[3]conway_0 [1.5mu p1.5mu][46]

[3]conway_0 [1.5mu q,p1.5mu][46]

[3]conway_0 (1[15]
[49]conway_0 (p:xs)[E]

[3]conway_0 (q[15]
[49]conway_0 (1:xs)[E]

[3]conway_0 (q[15]
[49]conway_0 ((q-1)[67]

[5]𝐰𝐡𝐞𝐫𝐞 p'[46]
[49]conway_0 (q[67]
where the order is reversed, because Conway's notation matches from
the right, but Haskell lists decompose from the left.  In order to
apply recursion abstraction successfully to this messy function, its
arguments need to be regularized and reordered in a particular way.
Firstly, we note that the first two cases, for lists of length less
than two, are special, in the sense that they are never reached by
recursion; the third case, for lists of length two exactly, is the
actual recursive base case.

Secondly, we notice that the remaining cases all involve two or more
numbers, and the nested recursion occurs quite inconveniently in
second position in the list.  Hence we separate a non-recursive
front-end function for the first two cases
[3]cfront_1 [12]
[12] [15]
[15][1.5mu 1.5mu][29]

[3]cfront_1 [12]
[12] [15]
[15][1.5mu p1.5mu][29]

[3]cfront_1 [12]
[12]b [15]
[32]b xs q p[E]
and a recursive back-end function, with the first two list elements
expanded and reordered, for the other cases
[3]cback_1 [11]
[11][1.5mu 1.5mu] [21]
[21]q [24]

[3]cback_1 [11]
[11](o:ys) [21]
[21]1 [24]
[47]cback_1 [55]
[55]ys [59]
[59]p [68]

[3]cback_1 [11]
[11](o:ys) [21]
[21]q [24]
[47]cback_1 [55]
[55]ys [59]
[59]1 [68]

[3]cback_1 [11]
[11]xs [21]
[21]q [24]
[47]cback_1 [55]
[55]xs [59]
[59](q-1) [68]

[6]𝐰𝐡𝐞𝐫𝐞 p'[44]
[47]cback_1 [55]
[55]xs [59]
[59]q [68]
such that
[3]conway≡cfront cback[E]
Note that the reordering of arguments, however unintuitive at first
glance, moves the nested recursion  from the awkward middle to a
more manageable final position.

Conway's arrows are traditionally defined starting from one rather
than zero.  But unlike for Knuth's arrows, there is no simple
extension to zero arguments.  In order to make the recursion pattern
more similar to the previous ones, we consider a variant where all
argument numbers are reduced by one in the front-end.[The notation
is actually  in Haskell.]
[3]cfront_2 [12]
[12] [15]
[15][1.5mu 1.5mu][38]

[3]cfront_2 [12]
[12] [15]
[15][1.5mu p1.5mu][38]

[3]cfront_2 [12]
[12]b [15]
[21]|length xs>1[38]
[41]cfront_1 b (map (- 1) xs)[E]
This gives us a slightly modified back-end:
[3]cback_2 [11]
[11][1.5mu 1.5mu] [21]
[21]q [24]

[3]cback_2 [11]
[11](o:ys) [21]
[21]0 [24]
[47]cback_2 [55]
[55]ys [59]
[59]p [68]

[3]cback_2 [11]
[11](o:ys) [21]
[21]q [24]
[47]cback_2 [55]
[55]ys [59]
[59]0 [68]

[3]cback_2 [11]
[11]xs [21]
[21]q [24]
[47]cback_2 [55]
[55]xs [59]
[59](q-1) [68]

[6]𝐰𝐡𝐞𝐫𝐞 p'[44]
[47]cback_2 [55]
[55]xs [59]
[59]q [68]

Note the two corrections  where arguments flow to results, and the single correction  where a recursive result flows back to an argument.

The first argument is the technical novelty of this exercise, because it is of list type.  We tackle it by double currying:
[3]cback_3 [11]
[11][1.5mu 1.5mu][24]

[3]cback_3 [11]

[5]𝐰𝐡𝐞𝐫𝐞 [12]
[12]aux [17]
[17]0 [20]
[43]cback_3 [51]
[51]ys [55]
[55]p [64]

[12]aux [17]
[17]q [20]
[43]cback_3 [51]
[51]ys [55]
[55]0 [64]

[12]aux [17]
[17]q [20]
[43]cback_3 [51]
[51]xs [55]
[55](q-1) [64]

[14]𝐰𝐡𝐞𝐫𝐞 p'[40]
[43]cback_3 [51]
[51]xs [55]
[55]q [64]

[3]cpow q p=(p+1)(q+1)[E]
Note the auxiliary function , and the use of en passant
pattern matching to unify the different heads of the three recursive cases.

The fold operator for lists takes generators with two arguments, a
non-recursive one for the head and a recursive one for the tail.  We
shape the auxiliary function accordingly by beta expansion,
[3]cback_3a [1.5mu 1.5mu][24]

[3]cback_3a xs@(o:ys)[24]
[27]aux o (cback_3a ys)[E]

[5]𝐰𝐡𝐞𝐫𝐞 [12]
[12]aux [17]
[17]o [20]
[20]k [23]
[23]0 [26]
[49]k [61]
[61]p [70]

[12]aux [17]
[17]o [20]
[20]k [23]
[23]q [26]
[49]k [61]
[61]0 [70]

[12]aux [17]
[17]o [20]
[20]k [23]
[23]q [26]
[49]cback_3 [57]
[57]xs [61]
[61](q-1) [70]

[14]𝐰𝐡𝐞𝐫𝐞 p'[46]
[49]cback_3 [57]
[57]xs [61]
[61]q [70]
make the, already familiar, context-sensitive substitution
[3]cback xs@(o:ys)≡aux o (cback ys)≡aux o k[E]
and eliminate the now unused variable  to obtain:B@>l<@
[3]cback_3b [1.5mu 1.5mu][21]

[3]cback_3b (o:ys)[21]
[24]aux o (cback_3b ys)[E]

[5]𝐰𝐡𝐞𝐫𝐞 [12]
[12]aux [17]
[17]o [21]
[21]k [24]
[24]0 [27]
[50]k [59]
[59]p [68]

[12]aux [17]
[17]o [21]
[21]k [24]
[24]q [27]
[50]k [59]
[59]0 [68]

[12]aux [17]
[17]o [21]
[21]k [24]
[24]q [27]
[50]aux o k [59]
[59](q-1) [68]

[14]𝐰𝐡𝐞𝐫𝐞 p'[47]
[50]aux o k [59]
[59]q [68]
We readily read off the universal property of list folding and deduce:
[3]cback_4=foldr aux cpow[E]

[5]𝐰𝐡𝐞𝐫𝐞 [12]
[12]aux [17]
[17]o [20]
[20]k [23]
[23]0 [26]
[49]k [58]
[58]p [67]

[12]aux [17]
[17]o [20]
[20]k [23]
[23]q [26]
[49]k [58]
[58]0 [67]

[12]aux [17]
[17]o [20]
[20]k [23]
[23]q [26]
[49]aux o k [58]
[58](q-1) [67]

[14]𝐰𝐡𝐞𝐫𝐞 p'[46]
[49]aux o k [58]
[58]q [67]
The remaining steps are business as usual.  Eliminate  from  by currying,
[3]cback_5=foldr aux cpow[E]

[7]aux [12]
[12]o [15]
[15]k 0[33]
[36]λp→k p o[E]

[7]aux [12]
[12]o [15]
[15]k q|q>0[33]

[9]𝐰𝐡𝐞𝐫𝐞 [16]
[16]aux2 [22]
[36]k [45]
[45]0 [54]

[16]aux2 [22]
[36]aux o k [45]
[45](q-1) [54]

[18]𝐰𝐡𝐞𝐫𝐞 p'[33]
[36]aux o k [45]
[45]q [54]
abstract from the “productive” self-reference by beta expansion,
[3]cback_5a=foldr aux cpow[E]

[7]aux [12]
[12]o [15]
[15]k 0[36]
[39]λp→k p o[E]

[7]aux [12]
[12]o [15]
[15]k q|q>0[36]
[39]aux2 (aux o k (q-1))[E]

[9]𝐰𝐡𝐞𝐫𝐞 [16]
[16]aux2 [22]
[22]f [25]
[39]k [48]
[48]0 [57]

[16]aux2 [22]
[22]f [25]
[39]f [57]

[18]𝐰𝐡𝐞𝐫𝐞 p'[36]
[39]aux o k [48]
[48]q [57]
and substitute
[3]aux o k q≡aux2 (aux o k (q-1))≡aux2 f[E]
to obtain:
[3]cback_5b=foldr aux cpow[E]

[7]aux [12]
[12]o [15]
[15]k [18]
[39]λp→k p o[E]

[7]aux [12]
[12]o [15]
[15]k [18]
[39]aux2 (aux o k (q-1))[E]

[9]𝐰𝐡𝐞𝐫𝐞 [16]
[16]aux2 [22]
[22]f [25]
[39]k [49]
[49]0 [58]

[16]aux2 [22]
[22]f [25]
[39]f [58]

[18]𝐰𝐡𝐞𝐫𝐞 p'[36]
[39]aux2 f [58]
Perform recursion abstraction in ,
[3]cback_6=foldr aux cpow[E]

[7]aux o k=foldn aux2 (λp→k p o)[E]

[9]𝐰𝐡𝐞𝐫𝐞 [16]
[16]aux2 [22]
[22]f [25]
[39]k [49]
[49]0 [58]

[16]aux2 [22]
[22]f [25]
[39]f [58]

[18]𝐰𝐡𝐞𝐫𝐞 p'[36]
[39]aux2 f [58]
beta-expand the auxiliary expression ,
[3]cback_7=foldr aux cpow[E]

[7]aux o k=foldn aux2 (λp→k p o)[E]

[11]aux2 [17]
[17]f [20]
[34]k 0 o[E]

[11]aux2 [17]
[17]f [20]
[34](λp'→f (p'-1)) (aux2 f (p-1))[E]
and perform recursion abstraction in :
[3]cback_8=foldr aux cpow[E]

[7]aux o k=foldn aux2 (λp→k p o)[E]

[9]𝐰𝐡𝐞𝐫𝐞 [16]
[16]aux2 f=foldn (λp'→f (p'-1)) (k 0 o)[E]

Final cosmetic translation for improved point-freeness:
[3]cback_9=foldr aux cpow[E]

[7]aux [13]
[13]o [16]
[23]foldn aux2 (flip k o)[E]

[9]𝐰𝐡𝐞𝐫𝐞 [17]
[17]aux2 f=foldn (f∘(- 1)) (k 0 o)[E]

§.§ Verification

Verification is a more complex issue here because of the sheer number
of cases in indirections.  Since no significant new insights are to be
gained, we give just one case, corresponding to the fourth equation of
, for illustration purposes:
[3]cfront_2 cback_8 (1:p:x)[31]
[35]cfront_1 cback_8 (map (- 1) (1:p:x))[E]

[35]cfront_1 cback_8 (0:p-1:x')[E]

[37]𝐰𝐡𝐞𝐫𝐞 x'=map (- 1) x[E]

[35]cback_8 x' 0 (p-1)[E]

[44]foldr aux cpow x' 0 (p-1)[E]

[35]aux o ([44]
[44]foldr aux cpow y) 0 (p-1)[E]

[37]𝐰𝐡𝐞𝐫𝐞 (o:y)=x'[E]

[35]foldn aux2 [47]
[47](λp→foldr aux cpow y p o) 0 [80]

[47](λp→foldr aux cpow y p o) [80]

[35]foldr aux cpow y (p-1) o[E]

[35]cback_8 y (p-1) o[E]

[35]cfront_1 cback_8 (p-1:o:y)[E]

[35]cfront_1 cback_8 (p-1:x')[E]

[35]cfront_1 cback_8 (map (- 1) (p:x))[E]

[35]cfront_2 cback_8 (p:x)[E]

§.§ Analysis

The type analysis of the recursion scheme of Conway's chained arrows
is analogous to the preceding examples.  The third, outermost layer of folding has yet a more complex underlying datatype.
[3]foldr_3::FoldR Integer (Integer→Integer→Integer)[E]

[3]cback_10=foldr_3 aux cpow[E]

[7]aux o k=foldn_2 aux2 (flip k o)[E]

[9]𝐰𝐡𝐞𝐫𝐞 [16]
[16]aux2 f=foldn_1 (f∘(- 1)) (k 0 o)[E]

§ CONCLUSION

Recursion abstraction is a sophisticated program transformation
technique.  Its straightforward applications are at the heart of the
algebra-of-programs approach to functional programming.  It is a
matter of taste whether definitions in terms of recursion operators
are more intuitive and readable than definitions in terms of
self-reference.  But without doubt, the primitive forms lends
themselves more easily to formal, in particular equational, reasoning.

Iterated recursion abstraction is notably more tricky than just a
single step.  Self-references need to be eliminated by clever
context-sensitive beta expansion.  The Ackermann function is, as for
many other questions, just the right introductory example to teach the
technique.  In particular, its argument order leads the way naturally.
Conway's chained arrow notation, on the other hand, is a significantly
more difficult nut to crack, and is rather at the high end of
demonstrations for the potential of the technique.

The central trick has now been used four times in three exercises, so the general pattern should have become apparent.  In summary, a multiply nested self-referential cycle in a definition is broken by bringing the function into the form
[3]h [6]

[3]h [6]
[20]g (h (n-1))[E]

[5]𝐰𝐡𝐞𝐫𝐞 [12]
[12]g f=i (h n)[E]
where the auxiliary higher-order function  typically arises
“virtually” by beta abstraction from a given expression in which  occurs.  Then one proceeds to
[3]h [6]

[3]h [6]
[20]g' (h (n-1))[E]

[5]𝐰𝐡𝐞𝐫𝐞 g' f=i (g' f)[E]
Globally,  and  are quite different functions, but we find for :
[3]g [7]
[7](h (n-1))≡i (h n)[31]
[35]i (g [42]
[42](h (n-1)))[E]

[3]g' [7]
[7](h (n-1))[31]
[35]i (g' [42]
[42](h (n-1)))[E]
That is, both  and , where , are fixed
points of .  Since we are in a functional programming language with
unique fixed point semantics as the very foundation of
self-referential definitions, we may substitute one for the other.
Then the outer recursion can be reduced to primitive form
[3]h=foldn e g'[E]

[5]𝐰𝐡𝐞𝐫𝐞 g' f=i (g' f)[E]
and the inner self-reference of  can be processed further by recursion abstraction, using either the same or more basic techniques.

It seems plausible that this technique will work for a large class of multiply nested recursive functions.  The auxiliary tactics that we have employed, namely moving nested recursion to final argument position and refactoring deep pattern matches, are possibly also more general heuristics, and merit further investigation.

§.§ Outlook

We close by posing several open problems as challenges to the reader:

* Assess whether the typical, relative ease of inductive reasoning about recursive functions in primitive form carries over to well-known, albeit non-trivial identities concerning our example functions, such as:
[3]ack (m+2) n≡knuth 2 m (n+3)-3[E]

* As an important special case of equational reasoning, demonstrate program simplifications, such as fusion rules, for expressions involving our example functions.

* Use the higher-order primitive recursion framework as a toolkit for synthesizing novel functions with interesting, recursive equational definitions.

§ ACKNOWLEDGMENTS

Anonymous referees of a previous manuscript have made valuable contributions to the evolution of this article.

[1]
R. Bird and O. de Moor.
Algebra of Programming.
Prentice Hall, 1997.

[2]
R. Cockett and T. Fukushima.
About Charity.
Technical report, University of Calgary, 1992.

[3]
G. Hutton.
A tutorial on the universality and expressiveness of fold.
J. Functional Programming, 9(4):355–372, 1999.

[4]
L. Meertens.
Formal Aspects of Computing, 4(5):413–425, 1992.

[5]
E. Meijer, M. M. Fokkinga, and R. Paterson.
Functional programming with bananas, lenses, envelopes and barbed
In J. Hughes, editor, Proc. International Conference on
Functional Programming Languages and Computer Architecture, volume 523 of
Lecture Notes in Computer Science, pages 124–144. Springer, 1991.

[6]
J. C. Reynolds.
Three approaches to type structure.
In Proc. International Joint Conference on Theory and Practice
of Software Development, volume 185 of Lecture Notes in Computer
Science. Springer, 1985.

[7]
R. M. Robinson.
Recursion and double recursion.
Bull. AMS, 54(10):987–993, 1948.

[8]
P. Wadler.
Recursive types for free!
Online manuscript, 1990.


# Topological Hall effect induced by chiral fluctuations in a kagome lattice

Kyle W. Fruhling1111These authors contributed equally to this work. , Alenna
Streeter1∗, Sougata Mardanya2,
Xiaoping Wang3, Priya Baral4, Oksana Zaharko4,
Igor I. Mazin5, Sugata Chowdhury2, William D. Ratcliff6,7, Fazel
Tafti${}^{1\,*}$
1Department of Physics, Boston College, Chestnut Hill, MA 02467, USA
2Department of Physics and Astrophysics, Howard University, Washington, DC
20059, USA
3Neutron Scattering Division, Oak Ridge National Laboratory, Oak Ridge, TN
37831, USA
4Laboratory for Neutron Scattering and Imaging (LNS), Paul Scherrer Institut,
PSI,
Villigen, CH-5232, Switzerland
5Department of Physics and Astronomy and Quantum Science and Engineering
Center,
George Mason University, Fairfax, VA 22030, USA
6NIST Center for Neutron Research, National Institute of Standards and
Technology,
Gaithersburg, ME 20899-6100, USA
7Department of Physics and Department of Materials Science and Engineering,
University of Maryland, College Park, Maryland 20742, USA
<EMAIL_ADDRESS>
One Sentence Summary: Chiral fluctuations at the boundary between
antiferromagnetic and ferrimagnetic phases produce a topological Hall effect
in the kagome magnet ErMn6Sn6.

> Topological Hall effect (THE) is a hallmark of scalar spin chirality, which
> is found in static skyrmion lattices. Recent theoretical works have shown
> that scalar spin chirality could also emerge dynamically from thermal spin
> fluctuations. Evidence of such a mechanism was found in the kagome magnet
> YMn6Sn6 where fluctuations arise from frustrated exchange interactions
> between Mn kagome layers. In YMn6Sn6, the rare-earth ion Y3+ is non-
> magnetic. When it is replaced by a magnetic ion (Gd3+–Ho3+), the
> intrinsically antiferromagnetic Mn-Mn interlayer coupling is overwhelmed by
> the indirect ferromagnetic Mn-$R$-Mn one, relieving frustration. This
> generates interesting anomalous Hall conductivity, but not THE. Here we show
> that Er lies in an intermediate regime where direct and indirect
> interactions closely compete, so that ErMn6Sn6 can switch from one regime to
> the other by temperature, i.e., from a collinear ferrimagnetic ground state
> to a spiral antiferromagnet at 78 K. The AFM phase forms a dome in the
> temperature-field phase diagram. Close to the boundary of this dome, we find
> a sizable fluctuations-driven THE, thus underscoring the universality of
> this mechanism for generating non-zero scalar spin chirality.

## Introduction

The unique geometry of the 2D kagome lattice leads to appreciable frustration
in the nearest neighbor magnetic or electronic tight-binding models. While
numerous materials with antiferromagnetic (AFM) kagome planes, usually
correlated insulators, have been investigated for spin-liquid behavior (?),
another class of interest is stacked ferromagnetic kagome layers, which
retains the peculiarity of the original kagome model in terms of electronic
structure, but not magnetic frustration (?). The electronic structure of such
materials is described by a frustrated hopping model, which was originally
restricted to $s$-orbitals only (?) but later extended to $d$-orbitals in
compounds with hexagonal symmetry (?). Since many of these materials are
magnetically ordered above room temperature and easily manipulated by doping,
they provide a fascinating playground for topology and magnetism to interact
on a kagome lattice and produce exotic behaviors in momentum space, such as
flat bands and Dirac crossings (?, ?, ?).

One such family of compounds, dubbed “166”, has attracted particular
attention. The general formula is $RT_{6}M_{6}$, where $R$ is a rare-earth,
$T$ is a 3d transition-metal, usually Mn, and $M$ is a metalloid of the group
13 or 14, most commonly Sn. In all these compounds, the Mn layers are metallic
and inherently ferromagnetic (FM); however, the coupling between layers and
the anisotropy of the ordered state depend on the rare-earth atom between the
layers (?, ?, ?). For example, TbMn6Sn6 has a strong Tb-Mn coupling and shows
an out-of-plane ferrimagnetic (FIM) order, which leads to a sizable anomalous
Hall effect (AHE) (?, ?, ?, ?). The non-magnetic rare-earths (Y and Sc) have
no $R$-Mn coupling and favor a spiral antiferromagnetic (AFM) coupling between
Mn layers, which leads to a sizable topological Hall effect (THE) (?, ?, ?).
In this paper, we discuss the peculiar case of ErMn6Sn6, a relatively less
studied member of the 166 family (?), which falls in a regime between the FIM
TbMn6Sn6 and spiral AFM YMn6Sn6.

As we will show here, the peculiarity of ErMn6Sn6 lies in the strength of the
Er-Mn coupling, which is non-zero unlike Y-Mn, but much weaker than Tb-Mn, so
the net sign of the Mn-Mn coupling can be reversibly switched by reducing the
ordered Er moment through thermal fluctuations. This leads to a change of
magnetic state from FIM at low temperatures (similar to TbMn6Sn6) to spiral
AFM at high temperatures (similar to YMn6Sn6). Using field-dependent
magnetization and neutron diffraction data, we show that the spiral AFM state
occupies a dome in the $H$-$T$ phase diagram. We also show that the field-
induced transition between these two states involves an intermediate regime of
fluctuating Mn moments. By performing detailed magneto-transport measurements,
we reveal a sizable THE in this fluctuating regime, i.e., at the boundary
between the spiral AFM phase (where ErMn6Sn6 is analogous to YMn6Sn6) and FIM
phase (where it is analogous to TbMn6Sn6). The magnitude of THE increases with
increasing temperature as expected from the fluctuation-driven mechanism.

## Results

### Magnetization

Figure 1:  Magnetic Phase Diagram. (A) Magnetic susceptibility of ErMn6Sn6 as
a function of temperature measured in both in-plane and out-of-plane field
directions and plotted on a semilog plot. (B-E) Magnetization as a function of
field at several temperatures. (F) Magnetic phase diagram constructed from the
in-plane magnetization data (black circles) and neutron diffraction data
(color map). The color map represents normalized integrated intensity under
incommensurate AFM Bragg peaks. (G) Neutron diffraction $\mathbf{Q}$ scan in
the (00L) direction showing a structural Bragg peak at the center and two
satellite magnetic peaks. The satellites indicate incommensurate AFM order at
$\mathbf{Q}=(0,0,2\pm\mathbf{k})$ with $\mathbf{k}=0.237$. (H) Field
dependence of the integrated intensity under the satellite peaks in panel (G)
reveal three regimes at 250 K. Error bars in this paper represent one standard
deviation.

ErMn6Sn6 has a high-temperature AFM transition marked by a peak at
$T_{\text{N}}$$=$346(3) K in Fig. 1A and a low-temperature FIM order marked by
a step in the in-plane susceptibility at $T_{\text{C}}$$=$78(8) K. The AFM
ordering has little anisotropy but the FIM order has a marked easy-plane
character, as seen in Fig. 1A. The evolution of anisotropy with temperature is
demonstrated in the magnetization curves of Figs. 1B-E. At low temperatures,
the out-of-plane magnetization ($H\|c$) saturates at a much higher field than
in-plane magnetization ($H\|b^{*}$, where $b^{*}$ is the direction orthogonal
to $a$). However, this anisotropy becomes less pronounced as temperature is
increased from $T_{\text{C}}$$=$78 K to $T_{\text{N}}$$=$346 K.

Using the magnetization curves in Figs. 1B-E and the supplementary Fig. S1, we
construct the magnetic phase diagram of ErMn6Sn6 for $H\|b^{*}$ and $H\|c$,
respectively, in Fig. 1F and the supplementary Fig. S2. Focusing on the red
curves ($H\|b^{*}$) in Figs. 1B-E, the $M(H)$ curve at 50 K (Fig. 1B) shows a
rapid saturation of the magnetic moment characteristic of FIM ordering.
However, the $M(H)$ curves at higher temperatures (Figs. 1C-E) show a linear
regime at low fields characteristic of AFM ordering, followed by a saturation
due to a field-induced transition from the AFM to FIM order. The black data
points in Fig. 1F trace this field-induced transition between AFM (linear
regime) and FIM (saturated regime) orders, revealing an AFM dome in the phase
diagram.

### Neutron Diffraction

We used single crystal neutron diffraction to characterize the FIM and AFM
structures, and study their evolution with magnetic field in the phase diagram
of Fig. 1F. It is instructive to start with the AFM dome at the center of the
phase diagram. Fig. 1G shows diffraction patterns at several fields along the
$\mathbf{Q}=(0,0,L)$ direction at 250 K. The central peak at
$\mathbf{Q}=(0,0,2)$ is a structural Bragg peak and the two satellites at
$\mathbf{Q}=(0,0,2\pm\mathbf{k})$, with $\mathbf{k}=0.237$, are incommensurate
AFM Bragg peaks. Previous diffraction studies at zero field (?) show that upon
decreasing temperature, these satellite peaks move closer to the structural
$(0,0,2)$ peak and merge with it at $T_{\text{C}}$$=$78 K, the temperature of
the AFM to FIM transition at $H=0$.

We studied the evolution of satellite peaks not only with temperature but also
with in-plane magnetic field ($H\|b^{*}$). As seen in Fig. 1G, the
incommensurate satellite peaks are suppressed with increasing in-plane field
and vanished at 3 T. By tracing the integrated intensity under these satellite
peaks as a function of field at 250 K, we reveal three regimes in Fig. 1H
shaded with red, white, and blue colors. In the low-field region ($H<1.5$ T,
red), we find a nearly unchanged magnetic intensity under the satellites peaks
in the incommensurate AFM phase. In the high-field region ($H>2.8$ T, blue),
the satellite peaks are completely suppressed and the system is in the field-
induced FIM phase. In the intermediate region ($1.5<H<2.8$ T, white), the
satellite peaks are gradually being suppressed. By repeating this analysis at
different temperatures (supplementary Figs. S3 and S4), we constructed the
phase diagram of Fig. 1F where the color scale corresponds to the integrated
intensity under the satellite peaks at different temperatures. The red region
is the incommensurate AFM phase where the satellite peaks are sizable. The
blue region is the FIM phase where satellite peaks have vanished. The white
region is the intermediate phase where the satellite peaks are being
suppressed with field.

A refinement of the neutron diffraction data in the FIM phase yields the
collinear in-plane magnetic structure shown in Fig. 2A. Details of the
magnetic refinements are presented in the supplemental Figs. S5 and S6 and
Tables S1 to S4. The Er and Mn magnetic moments are oppositely oriented with
the respective magnitudes of 8.0 $\mu_{\text{B}}$ and 2.3 $\mu_{\text{B}}$.
This structure is consistent with the zero-field ground state of ErMn6Sn6
reported in a prior work (?).

The refinement analysis in the AFM phase at 200 K with an incommensurate
$k$-vector (0, 0, 0.1959) produces a spiral order made of Mn-Er-Mn sandwich
layers which rotate by 70.4∘ with respect to each other. The magnetic unit
cell is approximately five times the structural unit cell (Fig. 2B). Within a
single Mn-Er-Mn sandwich layer, the Mn moments from the top and bottom Mn
layers form an angle $\phi$ and their net magnetization is canceled by the
oppositely oriented Er moments. This is the same double spiral order which has
been found in YMn6Sn6, now with a moment on the rare-earth site in ErMn6Sn6
(?). As seen in Fig. 1H, the transition between the spiral AFM phase and FIM
phase is not abrupt; it involves an intermediate regime of fluctuating Mn
moments. In the phase diagram of Fig. 1F, this fluctuating regime appears as a
pale region between the red (spiral AFM) and blue (FIM) regions. Our magneto-
transport measurements, presented below, reveal a sizable THE in this
fluctuating regime.

### Topological Hall Effect

The known mechanism of THE is due to the static scalar spin chirality (SSC) in
non-coplanar magnetic structures, for example, in a skyrmion lattice (?, ?,
?). Recently, a dynamical mechanism for the THE has been proposed where spiral
fluctuations, complementing an existing static spiral, generate a finite SSC
and thus a THE (?, ?, ?). In the 166 compounds, this mechanism is operative
only at finite temperatures, and only in a magnetic phase that is a transverse
conical spiral (TCS) propagating along the $c$-axis. A TCS naturally forms in
a material where the zero-field state is a helical spiral and an external
magnetic field $\mathbf{H}$ is applied in the $ab$-plane, a condition that is
realized at the AFM phase boundary in ErMn6Sn6 (Fig. 1F). A TCS state by
itself has zero SSC, but adding another spiral propagating in the direction
perpendicular to both $c$ and $\mathbf{H}$ generates a finite SSC. A simple
thermodynamic calculation (?) shows that such thermal excitations give a THE
that is proportional to the applied field, temperature, and
$M_{c}^{2}=M_{s}^{2}-M^{2}$, which is the projection of the Mn moment onto the
$c$ direction,

$\rho^{T}=\kappa\,M_{c}^{2}TH$ (1)

In a prior study of YMn6Sn6 with non-magnetic Y3+ ions (?), the variable
$M_{c}$ was readily available because Mn was the only magnetic species, and
the measured saturation magnetization was a good estimate of $M_{s}$, while
the field-dependent magnetization was $M$. Then, the prefactor $\kappa$ in Eq.
1 would be a constant. In ErMn6Sn6, however, Er3+ ions carry a large and
strongly temperature-dependent magnetization which prevents us from using Eq.
1 directly, even though it can be used separately at each individual
temperature. In other words, $\kappa$ becomes temperature dependent in
ErMn6Sn6. For simplicity, we first present a more conventional method of
extracting the THE and leave the implications of Eq. 1 to the Discussions.

Figure 2:  Topological Hall Effect. (A) Magnetic unit cell of ErMn6Sn6 in the
FIM ground state. Arrows in the Mn kagome layer (purple) and Er triangular
layer (green) correspond to their respective magnetic moments. Sn atoms are
not shown for simplicity. (B) Supercell rendering of the incommensurate
helical AFM order. A more detailed view is presented in the supplementary Fig.
S6. (C) Topological Hall effect ($\rho^{T}$) is extracted by subtracting the
ordinary ($\rho^{O}$) and anomalous ($\rho^{A}$) Hall effects from the total
Hall effect ($\rho^{H}$). (D) A second version of the phase diagram (Fig. 1F)
with a color map that corresponds to the intensity of the THE. (E)
Representative $\rho^{T}(H)$ curves at different temperatures.

We extract the THE from the total Hall signal as shown in Fig. 2C, by
subtracting the ordinary ($\rho^{O}\propto H$) and anomalous ($\rho^{A}\propto
M$) Hall effects from the total signal ($\rho^{H}$) to arrive at the
topological Hall effect ($\rho^{T}$) assuming $\rho^{H}=R_{0}H+4\pi
R_{s}M+\rho^{T}$. In the high field FIM state, this assumption holds well and
this equation simplifies to $\rho^{H}=R_{0}H+4\pi R_{s}M$. Then following the
procedure in Ref. (?), we can determine the high field anomalous and ordinary
Hall effects by plotting $\rho^{H}/M$ as a function of $H/M$ and extracting
the slope $R_{0}$ and intercept $4\pi R_{s}$. The typical treatment would
assume these are both constant; however, the electronic structure and hence
$R_{0}$ may be different in different magnetic phases. It also assumes that
the anomalous Hall effect remains proportional to the magnetization which is
not a fair assumption for spiral magnets. In the treatment we follow we
determine the ordinary Hall effect at low field as $\rho^{O}=\rho^{H}-4\pi
R_{s}M$, and then interpolate a cubic spline for $\rho^{O}$ between the AFM
and FIM states. The sum of the anomalous and ordinary Hall components is then
assumed to vary smoothly between phases. Thus the sum can be used to determine
$\rho^{T}$ even if the individual components are not accurately separated in
the AFM state. $\rho^{T}$ is then given by $\rho^{T}=\rho^{H}-R_{0}H-4\pi
R_{s}M$. The black, blue, and green lines in Fig. 2C show the ordinary,
anomalous, and topological components of the total Hall signal. We repeated
this analysis at different temperatures and made a color map of THE
($\rho^{T}$) in Fig. 2D. Our Hall data at different temperatures are presented
in the supplementary Fig. S7.

### First-Pinciples Calculations

Figure 3:  Magnetic Interactions and Electronic Structure. (A) Magnetic
interactions in the RMn6Sn6 system. The ground state magnetic configuration
for (B) YMn6Sn6, (C) ErMn6Sn6, and (D) TbMn6Sn6. (E)-(G) The orbital projected
electronic structure with spin-orbit coupling along the high symmetry path of
the Brillouin zone in YMn6Sn6, ErMn6Sn6, and TbMn6Sn6. The rare-earth f-states
are highlighted in orange color.

To understand the TCS magnetic phase and the emerging THE in ErMn6Sn6, we
compare it to its sister compounds YMn6Sn6 and TbMn6Sn6. All three compounds
share the same configuration of Mn3Sn Kagome layers sandwiched between two
inequivalent Sn2 and $R$Sn2 ($R$= Rare-earth) layers as shown in Fig. 3A.
Previous studies (?, ?) have shown that the competition between the magnetic
anisotropy of the rare-earth elements and Mn dictates the magnetic phase of
these compounds. YMn_6Sn_6 and TbMn_6Sn_6 lie at two extreme ends of this
picture. In YMn6Sn6, where the rare-earth element is nonmagnetic, the magnetic
anisotropy is fixed by the easy-plane anisotropy of the Mn layer. In this
case, the spiral ground state is well understood by a three-parameter
Heisenberg model, consisting of a ferromagnetic $J_{1}$ (across the Sn2
layer), antiferromagnetic $J_{2}$ (across the $R$Sn2 layer), and a
ferromagnetic $J_{3}$ (Fig. 3A). Replacing Y with the magnetic atom Tb changes
the magnetic anisotropy of the system into a strong easy axis. Additionally,
the interaction $J_{2}$ between Mn layers across the $R$Sn2 layer becomes
significantly larger in TbMn6Sn6 than in YMn6Sn6. Therefore, the strong
coupling from magnetic rare-earth enforces a collinear magnetic state with
out-of-plane moments for TbMn6Sn6.

ErMn_6Sn_6 lies in an intermediate regime between the Y and Tb compounds. A
comparison between the electronic structure of the three compounds is
presented in Figs. 3E-G. In these calculations, the strong correlation effects
of the $f$ and $d$ electrons are included by considering an effective onsite
Hubbard potential ($U_{\rm eff}=U-J$ ) (?, ?). We use $U^{\textrm{Er}}_{\rm
eff}$ = 8 eV, $U^{\textrm{Tb}}_{\rm eff}$ = 7 eV, following the recommendation
of Ref. (?), and $U^{\textrm{Mn}}_{\rm eff}$ = 0.5 eV. Close to the Fermi
level ($E_{\textrm{F}}$), the electronic structures of the Y and Er compounds
look nearly identical. This is because the Er-$f$ states lie well above the
$E_{\textrm{F}}$ (1.3 eV) and do not have much influence on the bands near the
Fermi level. In contrast, the Tb-$f$ states come closer to the
$E_{\textrm{F}}$ and enhance the Tb-Mn interaction. Therefore, the $R$-Mn
exchange coupling is expected to be smaller in ErMn6Sn6 than in TbMn6Sn6.

To verify this conjecture, we calculated the exchange coupling constants and
found that $J_{\textrm{Tb-Mn}}$ is at least four times larger than
$J_{\textrm{Er-Mn}}$ (140 meV vs. 32 meV). Given that the direct Mn-Mn
exchange coupling $J_{2}$ is AFM (and only weakly dependent on the rare earth)
but the indirect coupling is FM (Fig. 3A), the net interaction appears
antiferro- or ferromagnetic, and the ground state, correspondingly, spiral or
ferrimagnetic, depending on which component dominates. In the case of
ErMn6Sn6, at zero temperature, the FM component dominates, and the ground
state is the same as in TbMn6Sn6. However, at higher temperatures, the Er
moment starts to fluctuate (much more so than Mn, as shown in Ref. (?)), so
the indirect exchange coupling $J_{\textrm{R-Mn}}$ is reduced compared to the
direct coupling $J_{2}$, and eventually, the system switches to a spiral
state, similar to YMn6Sn6. With increasing field, this helical spiral
transitions to a flopped TCS state, as suggested by our neutron diffraction
data (the intermediate regime in Fig. 1H highlighted by white color). Note
that, unlike TbMn6Sn6, ErMn6Sn6 is, both experimentally and computationally
(?), easy-plane, so no spin-reorientation transition happens in the Er system,
unlike the Tb system (?).

## Discussion

By mapping the temperature and field dependence of the THE in ErMn6Sn6 (Fig.
2D), we reveal two characteristics that point toward a fluctuating order as
the underlying mechanism of the THE. First, the THE is observed only at the
boundary between the spiral and ferrimagnetic phases. Second, its magnitude
increases with increasing temperature as expected from Eq. 1. In the
supplementary materials, we use Eq. 1 to extract the THE signal and reproduce
the phase diagram of Fig. 2C (Figs. S8 and S9), confirming its connection with
Mn spin fluctuations.

The field dependence of the magnetic satellite peak intensities in Figs. 1F,H
show that an intermediate fluctuating magnetic phase (TCS) exists between the
spiral and ferrimagnetic phases. The THE emerges from the fluctuations of Mn
spins in this phase. Interestingly, the underlying spiral AFM state, the dome
in Fig. 1D, is in and of itself a result of fluctuations, but this time Er
instead of Mn. A prerequisite for that is reduced Er-Mn coupling, compared to
Tb-Mn. As seen in Fig. 3, the Tb-f bands are too close to $E_{\textrm{F}}$ in
TbMn6Sn6 unlike the Er-f bands in ErMn6Sn6, confirming the above picture.
Thus, both the nontrivial magnetic phase diagram and the THE are driven by
spin fluctuations, albeit of Er moments in the former, and Mn moments in the
latter.

## Materials and Methods

### Material Synthesis.

Single crystals of ErMn6Sn6 were grown using a self-flux technique. Erbium
pieces (99.9%), manganese granules (99.98%), and tin pieces (99.999%) were
mixed with the ratio Er:Mn:Sn = 1.25:6:18 and placed in an alumina crucible
inside an evacuated quartz tube. The excess amount (25%) of rare-earth was
necessary to eliminate impurity phases such as Mn3Sn2 and ErMnSn2. The quartz
tube was heated in a box furnace to 1000∘C at 3∘C/min, held at that
temperature for 12h, cooled to 600∘C at 6∘C/h, and centrifuged to remove the
excess flux. Using less amounts of rare-earth or centrifuging at $T<600$∘C
resulted in the formation of impurity phases.

### Characterizations.

Powder x-ray diffraction (PXRD) was performed using a Bruker D8 ECO instrument
in the Bragg-Brentano geometry, using a copper source (Cu-Kα) and a LYNXEYE XE
1D energy dispersive detector. The FullProf suite was used for the Rietveld
analysis (?) and the VESTA program was used for crystal visualizations (?).
Magnetization was measured using a Quantum Design MPMS3 with the sample
mounted on a low-background quartz holder. The electrical resistivity and Hall
effect were measured in a four-probe configuration using a Quantum Design PPMS
Dynacool.

### First-Pinciples Calculations

The magnetic and electronic structures of (Y,Er,Tb)Mn6Sn6 we calculated from
first-principle by including spin-orbit coupling within the framework of
density functional theory (DFT) (?) using the Vienna ab-initio simulation
package (VASP) (?, ?). The ground state electronic structure was obtained with
the projector augmented-wave pseudopotential, while the electron exchange-
correlation effects were implemented by the generalized gradient approximation
(GGA) (?) with Perdew-Burke-Ernzerhof (PBE) parametrization. The energy cut-
off of 350 eV was used for the plane-wave basis set, and the Brillouin zone
(BZ) integration was performed with a 9$\times$9$\times$7 $\Gamma$-centered
$k-$mesh (?). The total energy tolerance criteria are set to $10^{-8}$ eV to
satisfy self-consistency. We utilized experimental structure parameters and
optimized ionic positions until the residual forces on each ion were less than
10-2 eV/Å and the stress tensors became negligible.

In our calculations, we considered the inadequacy of DFT methods in respecting
the 2nd and 3rd Hund’s rules (?). The problem is that these methods include
spurious self-interaction of f-orbitals, which, because of their strong
localization, is larger than the spin-orbit and crystal field effects. As a
result, the occupation state of the f-shell becomes unstable and deviates from
the Hund’s rules depending on the magnetic structure. To circumvent this
problem, we used a patch to the VASP (?, ?) code, which allows nudging DFT+U
calculations into a given orbital configuration (?).

### Neutron Single Crystal Diffraction.

Zero-field neutron diffraction data for ErMn6Sn6 (Sample 1) were collected on
the time-of-flight single crystal diffractometer, TOPAZ, at the Spallation
Neutron Source, Oak Ridge National Laboratory (?). A plate-shaped crystal
measuring 0.49 x 3.16 x 3.25 mm was securely attached to a custom-built
aluminum pin with SuperGlue and then mounted on the TOPAZ ambient goniometer
for data collection at 200 K, with its temperature controlled by an LN2 Cobra
Cryostream. Data collection at 5 K used the TOPAZ cryogenic goniometer, with
sample temperature controlled by a Cryomech P415 pulse tube cryocooler.
Crystal orientations were optimized with the CrystalPlan program (?) (19 at
200 K and 20 at 5 K). Measurement for each orientation used approximately 1
hour of neutron beamtime, with 5 Coulombs of proton charge for SNS beam power
at 1.4 MW. A multiresolution machine learning algorithm was used for peak
integration. Data normalization, including neutron time-of-flight spectrum,
Lorentz, and detector efficiency corrections, followed previously reported
procedures (?). A spherical absorption correction with
$\mu=0.02155+0.05705\lambda$ mm-1 was applied. The reduced data were saved in
SHELX HKLF2 format, with the wavelength for each reflection recorded
separately and not merged. Magnetic structure solution and refinement were
performed using the JANA2020 program (?). The crystal structures at 200 K and
40 K from X-ray diffraction, both of $P6/mmm$ parent space group symmetry,
served as the starting models for magnetic structure refinements.

Neutron diffraction data under a magnetic field were measured on the thermal-
neutron single crystal diffractometer ZEBRA at SINQ of Paul Scherrer Insitut
(Villigen, Switzerland). The instrument was operated in the normal beam
geometry. An incoming neutron wavelength of 1.383Å (Ge monochromator) was
used. A crystal of dimensions 3.25 mm$\times$2.83 mm$\times$1 mm was mounted
in vertical 6 T or horizontal 7 T magnets with the $b^{*}$ crystal axis
vertical. In addition to temperature and magnetic field scans, data sets in
magnetic fields applied vertically were collected. 28 and 23 magnetic
reflections were measured at $T$= 200 K and $H$=1.5 T and $H$=3.5 T,
respectively, and were used for refinements of magnetic models using FULLPROF
and JANA.

## References

  * 1. M. Norman, Colloquium: Herbertsmithite and the search for the quantum spin liquid.  Reviews of Modern Physics 88, 041002 (2016).
  * 2. N. J. Ghimire, I. I. Mazin, Topology and correlations on the kagome lattice.  Nature Materials 19, 137-138 (2020).
  * 3. E. Tang, J.-W. Mei, X.-G. Wen, High-Temperature Fractional Quantum Hall States.  Physical Review Letters 106, 236802 (2011).
  * 4. Y. Lee, R. Skomski, X. Wang, P. P. Orth, Y. Ren, B. Kang, A. K. Pathak, A. Kutepov, B. N. Harmon, R. J. McQueeney, I. I. Mazin, L. Ke, Interplay between magnetism and band topology in Kagome magnets RMn6Sn6.  Physical Review B 108, 045132 (2023).
  * 5. I. I. Mazin, H. O. Jeschke, F. Lechermann, H. Lee, M. Fink, R. Thomale, R. Valentí, Theoretical prediction of a strongly correlated Dirac metal.  Nature Communications 5, 4261 (2014).
  * 6. A. Bolens, N. Nagaosa, Topological states on the breathing kagome lattice.  Physical Review B 99, 165141 (2019).
  * 7. M. Kang, L. Ye, S. Fang, J.-S. You, A. Levitan, M. Han, J. I. Facio, C. Jozwiak, A. Bostwick, E. Rotenberg, M. K. Chan, R. D. McDonald, D. Graf, K. Kaznatcheev, E. Vescovo, D. C. Bell, E. Kaxiras, J. van den Brink, M. Richter, M. Prasad Ghimire, J. G. Checkelsky, R. Comin, Dirac fermions and flat bands in the ideal kagome metal FeSn.  Nature Materials 19, 163–169 (2020).
  * 8. G. Venturini, B. C. E. Idrissi, B. Malaman, Magnetic properties of RMn6Sn6 (R = Sc, Y, Gd-Tm, Lu) compounds with HfFe6Ge6 type structure.  Journal of Magnetism and Magnetic Materials 94, 35–42 (1991).
  * 9. B. C. El Idrissi, G. Venturini, B. Malaman, D. Fruchart, Magnetic structures of TbMn6Sn6 and HoMn6Sn6 compounds from neutron diffraction study.  Journal of the Less Common Metals 175, 143–154 (1991).
  * 10. D. I. Gorbunov, M. D. Kuz’min, K. Uhlířová, M. Žáček, M. Richter, Y. Skourski, A. V. Andreev, Magnetic properties of a GdMn6Sn6 single crystal.  Journal of Alloys and Compounds 519, 47–54 (2012).
  * 11. X. Xu, J.-X. Yin, W. Ma, H.-J. Tien, X.-B. Qiang, P. V. S. Reddy, H. Zhou, J. Shen, H.-Z. Lu, T.-R. Chang, Z. Qu, S. Jia, Topological charge-entropy scaling in kagome Chern magnet TbMn6Sn6.  Nature Communications 13, 1197 (2022).
  * 12. S. Riberolles, T. J. Slade, D. Abernathy, G. Granroth, B. Li, Y. Lee, P. Canfield, B. Ueland, L. Ke, R. McQueeney, Low-Temperature Competing Magnetic Energy Scales in the Topological Ferrimagnet TbMn6Sn6.  Physical Review X 12, 021043 (2022).
  * 13. C. Mielke III, W. L. Ma, V. Pomjakushin, O. Zaharko, S. Sturniolo, X. Liu, V. Ukleev, J. S. White, J.-X. Yin, S. S. Tsirkin, C. B. Larsen, T. A. Cochran, M. Medarde, V. Porée, D. Das, R. Gupta, C. N. Wang, J. Chang, Z. Q. Wang, R. Khasanov, T. Neupert, A. Amato, L. Liborio, S. Jia, M. Z. Hasan, H. Luetkens, Z. Guguchia, Low-temperature magnetic crossover in the topological kagome magnet TbMn6Sn6.  Communications Physics 5, 1–9 (2022).
  * 14. D. C. Jones, S. Das, H. Bhandari, X. Liu, P. Siegfried, M. P. Ghimire, S. S. Tsirkin, I. I. Mazin, N. J. Ghimire, Origin of spin reorientation and intrinsic anomalous Hall effect in the kagome ferrimagnet TbMn6Sn6 (2022). ArXiv:2203.17246 [cond-mat].
  * 15. R. L. Dally, J. W. Lynn, N. J. Ghimire, D. Michel, P. Siegfried, I. I. Mazin, Chiral properties of the zero-field spiral state and field-induced magnetic phases of the itinerant kagome metal YMn6Sn6.  Physical Review B 103, 094413 (2021).
  * 16. N. J. Ghimire, R. L. Dally, L. Poudel, D. C. Jones, D. Michel, N. T. Magar, M. Bleuel, M. A. McGuire, J. S. Jiang, J. F. Mitchell, J. W. Lynn, I. I. Mazin, Competing magnetic phases and fluctuation-driven scalar spin chirality in the kagome metal YMn6Sn6.  Science Advances 6, eabe2680 (2020).
  * 17. H. Zhang, C. Liu, Y. Zhang, Z. Hou, X. Fu, X. Zhang, X. Gao, J. Liu, Magnetic field-induced nontrivial spin chirality and large topological Hall effect in kagome magnet ScMn6Sn6.  Applied Physics Letters 121, 202401 (2022).
  * 18. J. Casey, S. S. Samatham, C. Burgio, N. Kramer, A. Sawon, J. H. and, A. K. Pathak, Spin-flop quasi metamagnetic, anisotropic magnetic, and electrical transport behavior of Ho substituted kagome magnet ErMn6Sn6 (2023).
  * 19. B. Malaman, G. Venturini, R. Welter, J. P. Sanchez, P. Vulliet, E. Ressouche, Magnetic properties of RMn6Sn6 (R=Gd–Er) compounds from neutron diffraction and Mössbauer measurements.  Journal of Magnetism and Magnetic Materials 202, 519–534 (1999).
  * 20. T. Kurumaji, T. Nakajima, M. Hirschberger, A. Kikkawa, Y. Yamasaki, H. Sagayama, H. Nakao, Y. Taguchi, T.-h. Arima, Y. Tokura, Skyrmion lattice with a giant topological Hall effect in a frustrated triangular-lattice magnet.  Science 365, 914–918 (2019).
  * 21. Q. Shao, Y. Liu, G. Yu, S. K. Kim, X. Che, C. Tang, Q. L. He, Y. Tserkovnyak, J. Shi, K. L. Wang, Topological Hall effect at above room temperature in heterostructures composed of a magnetic insulator and a heavy metal.  Nature Electronics 2, 182–186 (2019).
  * 22. N. Verma, Z. Addison, M. Randeria, Unified theory of the anomalous and topological Hall effects with phase-space Berry curvatures.  Science Advances 8, eabq2765 (2022).
  * 23. Q. Wang, K. J. Neubauer, C. Duan, Q. Yin, S. Fujitsu, H. Hosono, F. Ye, R. Zhang, S. Chi, K. Krycka, H. Lei, P. Dai, Field-induced topological Hall effect and double-fan spin structure with a $c$-axis component in the metallic kagome antiferromagnetic compound YMn6Sn6.  Physical Review B 103, 014416 (2021).
  * 24. M. Afshar, I. I. Mazin, Spin spiral and topological hall effect in Fe3Ga4.  Phys. Rev. B 104, 094418 (2021).
  * 25. V. I. Anisimov, J. Zaanen, O. K. Andersen, Band theory and mott insulators: Hubbard $\mathrm{U}$ instead of stoner $\mathrm{I}$.  Phys. Rev. B 44, 943 (1991).
  * 26. V. I. Anisimov, F. Aryasetiawan, A. I. Lichtenstein, First-principles calculations of the electronic structure and spectra of strongly correlated systems: the $\mathrm{LDA+U}$ method.  Journal of Physics: Condensed Matter 9, 767 (1997).
  * 27. A. Galler, L. V. Pourovskii, Electronic structure of rare-earth mononitrides: quasiatomic excitations and semiconducting bands.  New Journal of Physics 24, 043039 (2022).
  * 28. J. Rodríguez-Carvajal, Recent advances in magnetic structure determination by neutron powder diffraction.  Physica B: Condensed Matter 192, 55–69 (1993).
  * 29. K. Momma, F. Izumi, VESTA 3 for three-dimensional visualization of crystal, volumetric and morphology data.  Journal of Applied Crystallography 44, 1272–1276 (2011).
  * 30. P. Hohenberg, W. Kohn, Inhomogeneous electron gas.  Physical review 136, B864 (1964).
  * 31. G. Kresse, J. Furthmüller, Efficient iterative schemes for ab initio total-energy calculations using a plane-wave basis set.  Physical review B 54, 11169 (1996).
  * 32. G. Kresse, D. Joubert, From ultrasoft pseudopotentials to the projector augmented-wave method.  Physical review b 59, 1758 (1999).
  * 33. J. P. Perdew, K. Burke, M. Ernzerhof, Generalized gradient approximation made simple.  Physical review letters 77, 3865 (1996).
  * 34. H. J. Monkhorst, J. D. Pack, Special points for brillouin-zone integrations.  Phys. Rev. B 13, 5188 (1976).
  * 35. J. P. Allen, G. W. Watson, Occupation matrix control of d- and f-electron localisations using dft + u.  Phys. Chem. Chem. Phys. 16, 21016-21031 (2014).
  * 36. L. Coates, H. B. Cao, B. C. Chakoumakos, M. D. Frontzek, C. Hoffmann, A. Y. Kovalevsky, Y. Liu, F. Meilleur, A. M. dos Santos, D. A. A. Myles, X. P. Wang, F. Ye, A suite-level review of the neutron single-crystal diffraction instruments at Oak Ridge National Laboratory.  Review of Scientific Instruments 89, 092802 (2018).
  * 37. J. Zikovsky, P. F. Peterson, X. P. Wang, M. Frost, C. Hoffmann, CrystalPlan: an experiment-planning tool for crystallography.  Journal of Applied Crystallography 44, 418–423 (2011). Publisher: International Union of Crystallography.
  * 38. A. J. Schultz, M. R. V. Jørgensen, X. Wang, R. L. Mikkelson, D. J. Mikkelson, V. E. Lynch, P. F. Peterson, M. L. Green, C. M. Hoffmann, Integration of neutron time-of-flight single-crystal Bragg peaks in reciprocal space.  Journal of Applied Crystallography 47, 915–921 (2014). Publisher: International Union of Crystallography.
  * 39. V. Petříček, L. Palatinus, J. Plášil, M. Dušek, Jana2020 – a new version of the crystallographic computing system jana.  Zeitschrift für Kristallographie - Crystalline Materials 238, 271–282 (2023).

Acknowledgements: The authors thank M. Newburger and M. Page for insightful
discussions, and O. Remcho, X. Yao, and T. Hogan for assistance with the
experiments. The work at Boston College was supported by the National Science
Foundation under Award No. DMR-2203512. The work at Howard University was
supported by the U.S. Department of Energy (DOE), Office of Science, Basic
Energy Sciences under Award No. DE-SC0022216. This research at Howard
University used resources of the National Energy Research Scientific Computing
Center, a DOE Office of Science User Facility supported by the Office of
Science of the U.S. Department of Energy under Contract No. DE-AC02-05CH11231
using NERSC award BES-ERCAP0023852 and Accelerate ACCESS PHY220127. Our
neutron scattering experiments were performed at the Swiss Spallation Neutron
Source SINQ, Paul Scherrer Institut, Switzerland, and the Spallation Neutron
Source, a DOE Office of Science User Facility operated by the Oak Ridge
National Laboratory, USA. P.B. thanks SNSF projects 200021-188707 and
200020-182536 for financial support. Certain commercial products or company
names are identified here to describe our study adequately. Such
identification is not intended to imply recommendation or endorsement by the
National Institute of Standards and Technology, nor is it intended to imply
that the products or names identified are necessarily the best available for
the purpose.
Author Contributions: K.W.F. grew the crystals and performed magnetization and
transport characterizations. A.S., X.W., P.B., O.Z., and W.D.R. performed
neutron diffraction experiments. S.M. and S.C. calculated the band structure
and electronic properties. W.D.R., I.I.M. and F.T. conceptualized and
organized the project. All authors participated in the discussions and in
writing the paper.
Competing Interests: The authors declare no competing interests.
Data and materials availability: Additional data and materials are available
online.
Supplementary Material: Supplementary materials include a PDF file and two
mCIF files.