{'fraction_non_alphanumeric': 0.03790219801323347, 'fraction_numerical': 0.011225754639571222, 'mean_word_length': 4.398171708604279, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Diagrammatics for the Inverse Problem in Spin Systems and Simple Liquids

Modeling complex systems, like neural networks, simple liquids or flocks of birds, often works in the inverse way as textbook approaches: given data for which averages and correlations are known, we try to find the parameters of a given model consistent with it. In general, no exact calculation directly from the model is available and we are left with expensive numerical approaches. A particular situation is that of a perturbed Gaussian model with polynomial corrections for continuous degrees of freedom. Indeed perturbation expansions for this case have been implemented in the last 60 years. However, there are models for which the exactly solvable part is non-Gaussian, such as independent Ising spins in a field, or an ideal gas of particles. We implement a diagrammatic perturbative scheme in weak correlations around a non-Gaussian yet solvable probability weight. This applies in particular to spin models (Ising, Potts, Heisenberg) with weak couplings, or to a simple liquid with a weak interaction potential. Our method casts systems with discrete degrees of freedom and those with continuous ones within the same theoretical framework. When the core theory is Gaussian it reduces to the well-known Feynman diagrammatics.


Motivations
Consider a many-body problem, such as one involving interacting spins or particles, for which the available data, whether experimental or numerical, allows us to determine the corresponding averages and two-point correlation functions. Suppose the distribution of the spin values or of the particle positions is written in a Boltzmann form with oneand two-body interactions only. One question we wish to adress is how to choose the corresponding couplings so that the distribution generates the correct two-point correlations. Such inverse problems are of course ubiquitous in the study of complex systems from simple fluids to neurons or proteins (see for instance [1,2,3,4,5,6]). In general, making analytical progress for inverse problems requires to resort to approximation schemes. Even when only the averages of the degrees of freedom are constrained this is a formidable task equivalent to solving a statistical mechanical model with a one-body external field. Outside the realm of Gaussian theories which are exactly solvable, few generic methods exist [7,8,9,10,11]. If one further constrains correlations to be fixed, the problem has been adressed at the field-theoretic level (that rests on an expansion around a Gaussian theory) and is known under various names: Luttinger and Ward, or 2PI, or effective potential methods [12,13]. Within the realm of simple liquids, the Poisson nature of statistics of the ideal gas has also been exploited [14,15,16] to derive a one-to-one connection between the pair potential and the pair distribution function. For Ising spins (binary variables), weak correlation expansions have been carried out as well [4]. However, it is our feeling that, however remarkable, these inroads into specific systems, such as simple liquids or Ising spins, could benefit a more general approach, applicable, e.g. to Potts spins or even, more speculatively, to trajectory-dependent observables [17,18,19].
We begin by introducing the framework designed to work at given two-point correlations in Section 2, by introducing a Legendre transform with respect to correlations, just as is used in the Luttinger-Ward approach. This leads us to defining a free-energy like functional of the two-point function, which attains its minimum at the prescribed physical two-point correlation function. We then outline our perspective on the diagrammatic expansion of this technique around Gaussian theories in Section 4, reproducing the classical results for this case. The main novelty of this work is to show that a related diagrammatic expansion of this functional in the correlations is possible, provided the one-body problem is solvable, though not necessarily characterized by a Gaussian distribution. Equipped with this tool, we then implement the procedure on the Ising model, where the Sessak and Monasson results [4] are readily recovered, and further extended to q-state variables (q ≥ 2). After that, we show that our approach is consistent with the Hiroike-and-Morita expansion [14] for simple liquids, and fieldtheoretic approaches based on the Luttinger-Ward functional. In our conclusion we suggest interesting applications.

The second Legendre transform
Let H [ψ] be a dimensionless Hamiltonian for a field ψ x , where ψ x and/or x can be living in a discrete or continuous space (for a discrete ψ, dψ . . . refers to a summation over the allowed values of ψ). For this Hamiltonian, we define the cumulant-generating functional W [j, K] = ln dψ e −H[ψ]+j T ψ+ 1 2 which depends not only on a source term j for the field ψ, but also on a symmetric source K coupled to a two-point observable. The sources j and K live in the same x-space as the field ψ, and we shall resort to the notational shortcut where the integration sign is replaced with a discrete summation depending on the discrete/continuous nature of x. Since we are interested in investigating an inverse problem, where the first two moments of ψ are prescribed, we find it convenient to Legendre transform W with respect to both sources. Consider the functional Γ depending on a one-body field φ and on a symmetric two-body field ∆ defined by In particle and condensed-matter physics [12,13], this is known as the Luttinger-Ward or Baym-Kadanoff functional or 2PI functional, in liquid-state theory as the Morita-Hiroike functional and in statistics as maximum log-likelihood (at given second-order statistics). In the remainder, we will refer to it as the effective potential and denote it by Γ. At the supremum in expression (3) we have The functional derivatives of Γ are found to be given by δΓ δφ x = j x + y K x,y φ y , δΓ δ∆ x,y = K x,y (5) and in the physically relevant limit of vanishing sources j and K, these (5) make up the equations of state in the sense that they determine the values of the one and two-point correlations, φ x = ψ x and ∆ = ψ x ψ y − ψ x ψ y : The functional Γ is minimized when φ and ∆ are, respectively, the one-point and connected two-point correlation functions.
These relations tell us that if we were able to determine Γ exactly, then by performing the corresponding functional derivatives in (5), we would solve the inverse problem. This is of course a very difficult problem due to the presence of interactions. The idea is thus to separate the one-body problem, which we assume to be solvable (in the sense that the corresponding effective potential can be found exactly), and to expand the functional in powers of the correlations induced by two-body interactions.
To prepare for the implementation of this expansion, we derive an expression for Γ without explicit reference to the Legendre transform. We use the definition of Γ, Eq. (3), with the conditions Eqs. (4) on j and K, to arrive at = exp φj = exp φ δΓ δφ − δΓ δ∆ φ + 1 2 where we have made use of Eq. (5) to express the source terms j and K in terms of derivatives of Γ and we have implied the summation over indices. We finally isolate Γ and replace the field ψ with its expression as a derivative with respect to j. This leads to At this stage, no approximation has been made, and Eq. (9) is fully exact. The next section sets the stage for the perturbation expansion, and introduces a diagrammatic procedure to perform a weak correlation expansion.

A useful identity on the contribution of interactions
Consider the situation in which H is the sum of a solvable part H 0 and of a perturbation H int . We take Γ 0 to be the first Legendre transform of the unperturbed part. If the unperturbed theory remains solvable upon introducing a two-point source (as is the case for a quadratic H 0 ), we can also choose Γ 0 to be its second Legendre transform. We further comment this in appendix 11.1. We then define Γ int by We now plug Eq. (11) into Eq. (10) and isolate Γ int on the left hand side, which yields where To obtain Eq. (12), we have replaced the term e Γ 0 − δΓ 0 δφ φ with e −W 0 . The field j is evaluated at δΓ 0 δφ . This equation is the starting point for the diagrammatics to be developed in the next section.

Towards an expression that can be analyzed with diagrams
In order to proceed with diagrammatics, we will closely follow the footsteps of Kühn and Helias [11]. Indeed, our starting expression Eq. (12) differs from their Eq. (12) by an additional term due to the two-point source in Eq. (13). For completeness, we carry out-and adapt-the reasoning from scratch. Our approach here is rather formal, and we refer readers familiar to the theory of simple liquids to appendix 11.2.1 where we illustrate these ideas in the language of Mayer diagrams. There, we give a proof of the first Mayer theorem (also known as the linked-cluster theorem: W is represented by all connected diagrams) for the example of a simple liquid, using the slightly easier-tomanipulate cumulant-generating function instead of the effective potential.
We would like to construct the full theory order by order, using Eq. (12), so we start by defining the functional g l,L by Comparing this expression with Eq. (12), we obtain Γ int from g l,L via which defines g. Using that we derive a recursion relation for g l,L : where g 0,L = W 0 for all L. We now give a diagrammatic interpretation to this equation.

Constructing a diagrammatic expansion
To interpret Eq. (17) diagrammatically let us first discuss the effect of line (18). This line tells us that in order to construct the diagrams of order l, we have to combine one (bare) interaction with diagrams containing 0 to l − 1 interactions. For instance, taking as an example a four-point interaction perturbing a Gaussian theory (W 0 only contains cumulants of order 1 and 2), to first order, we obtain the following diagrams A circle (node) with n legs represents an n-th order cumulant of the unperturbed theory, which are generated by letting the j-derivatives acting on g l,L (we recall that constructing the first order l = 1, g l−1=0,L is identical to W 0 ). The crossing of k lines represents a k-point interaction.
A diagram is translated into a numerical value as follows: Consider that at every leg of the interaction, we have a j-derivative acting on e W 0 [j] . Then we have to count the ways to obtain an expression represented by the first diagram of Eq. (21). The first derivative simply yields W (1) [j] e g l,L [j] . The second derivative also acts on the prefactor-then the other two together have to generate the other propagator-or it produces another W (1) [j]-prefactor. In the latter case, we can pick one out of two W (1) [j] to let one of the remaining j-derivatives act upon. For the last derivative, we have no choice whatsoever. Because all these contributions yield the same value, we have to count the diagram three times. We will call this the symmetry prefactor of the diagram. It can be determined more conveniently considering the topology of the diagram: Assume that we label the legs of the diagram, say with the indices i 1 to i 4 . Then, we have three possibilities to choose those legs of the interaction joined by a second-order cumulant. In other words, we obtain the symmetry factor of a diagram by labeling its vertices (and, with them, the cumulants) and count the symmetry operations that leave the unlabeled diagram unchanged, but leads to new labeled diagrams (that is join (i 1 , i 2 ) and (i 3 , i 4 ), (i 1 , i 3 ) and (i 2 , i 4 ) or (i 1 , i 4 ) and (i 2 , i 3 )). So, naming the four-point interaction U, we translate where summations over places or momenta are implied.
Determining the symmetry factors for the second diagram of the first order in U, we need to pick 2 out of 4 legs that are connected by a second-order cumulant. We have 4 2 = 6 possibilities to do that, so the symmetry factor is 6. Generating the third diagram, there is nothing to choose, so the symmetry factor is 1.
In diagrams with more than one interaction, in addition, we have to count the possibilities to distribute them. Creating them, the j-derivatives might act not only on W 0 , but also on the higher orders of g l,L already generated. By determining the symmetry factor of such a diagram as a whole we can assume that in every iteration step, at most one interaction was added. In this case, one has L k possibilities to pick each of these interactions, so in the limit of L tending to infinity, the prefactor is given by because every interaction vertex comes with a 1/L prefactor. If, however, there are more vertices in a diagram than there are iteration steps to construct it (because we have connected several parts of g l,L both containing vertices by a new vertex), then the interactions still come with a prefactor 1/L, but we only have L k ′ possibilities to pick them, with k ′ < k and so these contributions vanish in the limit of L tending to infinity. Therefore, we can neglect this possibility.
We remember that g l,L is a functional of j and we obtain Γ int only after inserting j = δΓ 0 δφ (and taking the limit of L → ∞). This becomes particularly important when discussing the effect of the lines (19) and (20). They lead to diagrams consisting of one cluster stemming from the derivative of Γ with respect to φ or ∆, which are attached to the remainder via one or two cumulants, respectively. The subtraction of φ in Eqs. (19) and (20) removes all diagrams coming about by attaching the δΓ δφ -cluster to isolated first-order cumulants of the unperturbed theory: Note that the cancelation only gets effective upon inserting j = δΓ 0 δφ . We indicate this by denoting derivatives of W 0 evaluated at a variable j by open circles and proper cumulants (the derivatives evaluated at j = δΓ 0 δφ ) by filled circles. This indicates that these two contributions are equal after inserting the proper value for j. However, the contribution from both diagrams in Eq. (24) remain in g l,L , j-derivatives act only on the first one in further iteration steps.
The treatment of j-derivatives acting on g l,L for l > 0, especially in line (20) containing the ∆ derivative is a bit more subtle. We start by discussing its role in the Gaussian case, for which it is nearly analogous to that of line (19).

Recovering the expansion around a Gaussian theory
Compared to Eq. (13) in [11], we have obtained an additional contribution stemming from the two-point source. If the unperturbed theory is Gaussian, we can therefore proceed largely analogously to the first Legendre transform. Then, Eq. (19) removes one-particle reducible diagrams and Eq. (20) removes two-particle reducible diagrams.
We have already seen in Eq. (24) that, as a rule, Eq. (19) does not contribute in the first step of the iteration. However, the starting point for the iteration could still be ill-defined in case Eq. (20) already contributed at this stage. To avoid this, we have to make sure that also the second of these lines does not yield any nonzero contribution in case the j-derivatives solely act on W 0 and not on a diagram with interactions. To achieve this, the propagator of the unperturbed theory is chosen to be ∆, so that, being applied to W 0 only, (20) vanishes as well. Therefore, in the first iteration step, indeed only (18) contributes to the iteration. In the next steps, the derivatives of Γ int with respect to φ and ∆ are easy to evaluate because Γ int is a multinomial in φ and ∆. Diagrammatically, a φ-derivative then correponds to the removal of a dangling leg and a ∆-derivative to the removal of a propagator line, e.g.
(the additional prefactors emerging from the derivatives are implied in the symmetry factors of the diagrams on the right hand sides). Letting (19) act on a cluster contained in some g l ′ ,L for some l ′ ≤ l generates a one-particle reducible diagram. The same is produced by (18), but with the opposite sign so that both contributions cancel out: Line (20) generates two kinds of contributions: the two j-derivatives can either act on the same cluster or on different ones. The first type of contributions ( Figure 1, left) cancels two-particle reducible contributions emerging from line (18), whereas the second generates diagrams that are one-particle reducible at (at least) two points (Figure 1, right). The latter are again canceled by the corresponding diagrams emerging from line (19).
In both cases of cancelation, we not only used that the diagrams are topologically identical, but also tacitly assumed that their symmetry factors were the same. Let us convince ourselves that this is actually the case. Consider a diagram with a cluster containing k interactions connected to the remainder, containing n − k interactions, by only one propagator line (or two, considering (20)). In case we produce this diagram only using bare interactions, we have n k possibilities to pick k interactions for the cluster. This yields 1 n! n k = 1 k!(n−k)! as a prefactor, same as when the cluster is contributed from the derivative of Γ. The remaining symmetry operations fixing the symmetry prefactor are determined considering the cluster and the remainder separately. This indeed yields the same symmetry factor in either case to generate the diagram of the same topology. Formally, we also could have chosen Γ 0 to be the second Legendre transform of the Gaussian theory and not its first. This approach is lengthier, but conceptually somewhat cleaner because by introducing the two-point source K at this stage allows us to treat φ and ∆ on the same footing: they are both determined by the choice of j and K.
In principle, this choice also offers one way to generalize to correlated non-Gaussian theories, as we discuss in appendix 11.1. This generalization, however, is only of limited interest because it requires the unperturbed theory to remain solvable after adding the two-point source. But if the unperturbed theory is uncorrelated, this is in general not the case. For the Ising model and a simple liquid, for example, the interaction has precisely the form of the two-point source term. We therefore have to treat this scenario separately, which we defer to Section 5.

Uncorrelated unperturbed theory
If the unperturbed theory augmented with a two-point source term K cannot exactly be solved, then we cannot cancel the corresponding term in the iteration equation, (20) in the first step. This is not a problem, but certainly means that the initial step of the iteration to generate Γ int has to be different from the Gaussian case. What helps us here is that correlations are small and therefore, Eq. (20) can be treated order by order in the magnitude of the correlations. The only complication is that the concrete form of this perturbation is not a priori given, but it follows from the derivatives of the contribution to Γ int from lower orders. For this reason, the zeroth, first and second order of Γ are special cases, so we treat them separately from higher order terms. We denote the n-th order contribution to Γ int as Γ int,n .

Zeroth, first and second order
For simplicity, we first assume only a single type of interaction, namely the two-point one. It can be absorbed into δΓ δ∆ so that line (18) is removed from the iteration equation: One can read off already from this form of the operator that diagrams containing "dangling legs", that is cumulants of order 1, are canceled because every j-derivative is accompanied by a −φ.
Zeroth order Evaluating Eq. (12) at zeroth order in the interaction clearly yields 1 on the left hand side. This tells us that the application of A δ δj has to yield 0 at this step. Because we reduce Γ int by one order in the interaction by differentiating with respect to ∆, we have We conclude that the right-hand side of Eq. (12) only vanishes to zeroth order in ∆ if δΓ int,1 δ∆ = 0 and therefore Γ int,1 = 0 (Γ int,1 must vanish because it is proportional to ∆ by definition).
First order Comparing the first order on both sides, we have 1 from Γ int,1 = 0 on the left-hand side and on the right-hand side. All nontrivial terms of order ∆ vanish, as they should, because the j-derivatives of W 0 yield φ after evaluation (note that δΓ int,2 δ∆ ∆ is of order 2).
Second order This is the first non-vanishing order. Its most general form reads where we separated the 1 2 prefactors from the definition of F for later convenience. We observe that To evaluate (12) neglecting terms of order 3 or higher, we first rewrite its second-order expansion, bringing the last term in the operator (13), 1 2 δΓ int,2 δ∆ [φ, ∆] ∆, to the left-hand side so that we obtain (using again that Γ int, where Here again, acting with the A-operator on W 0 just once yields zero, so that the only non-vanishing contribution is where we introduced the second cumulants of the unperturbed theory, κ x 2 . Correspondingly, we call the nth order cumulants of the unperturbed theory κ x n . Diagrammatically, the right-hand side is represented by where we introduced the notation and the prefactors on the right-hand side of Eq. (35) indicate how we evaluate the diagram. The 1 2 comes from the order in the interaction, the 1 2 2 from the definition of the interaction and the 2 is the symmetry-factor of the diagram: flipping one interaction vertex generates a new labeled diagram, flipping both at once does not. Inserting the form Eq. (28) into Eq. (34), we obtain the tensor equation which is solved by and, consequently, In higher orders, M will play the same role in the diagrammatics as the two-point interaction does for the first Legendre transform.

Third and higher orders
Before proceeding to constructing further diagrams, we recall the meaning of their constituting elements defined so far and introduce two new ones: The difference between the empty and the full nodes is that the first represent derivatives of the cumulant-generating functional at arbitrary sources, whereas the full ones indicate that we have inserted j = ∂Γ 0 ∂φ -so these nodes represent the actual cumulants. Because the (first) Legendre transform is involutive, we furthermore have = 1 . Singling out the terms stemming from the second order of Γ int (using M xy = δΓ int,2 δ∆xy ), which we subtract and then add in a different form, we now start from which leads to the following iteration equation for g l,L : where we abbreviated Γ int, =2 = Γ int − Γ int,2 . Calling Γ int,n the interaction term of order n, the term δΓ int,n δ∆ is of order n − 1, which means that, combined with M or the term ∆ in Eq. (45), it yields a term of order n. However, we see that these two contributions actually cancel out because This result comes about by observing that any W 0 -derivative generated in Eq. (47) of order higher than 2 is multiplied by at least a first-order one, so those terms are eventually canceled by inserting j = δΓ δφ and considering the respective (−φ)contribution. Therefore, the only non-vanishing contribution arises from terms in which either x = x ′ , y = y ′ or x = y ′ , y = x ′ and the respective pairs of j-derivatives generate two second-order cumulants. Due to these two possibilities, the 1 2 is turned into unity. We therefore obtain the contributions to the n-th order by combining clusters from δΓ k δ∆ for k < n in all possible ways such that the total number of correlations in the diagram equals n. This enables the explicit iterative construction of all higher-order contributions, which is one of the main results of this work.
Third order Here, concretely, we construct all diagrams without dangling legs containing M xy three times. This yields the same diagrams as for the first Legendre transform. We explicitly write the minus sign appearing in the left-hand side of Eq. (15): These diagrams have the "ring" and the "watermelon" topology also encountered in Feynman diagrammatics. For the construction of higher orders, we have to consider ∆-derivatives of the third-order contributions to Γ int as additional interactions. We therefore want to determine the symmetry factor of clusters with one ∆ correlation removed. Since we perform a ∆ derivative, we have to fix a pair of outer indices. Because correlations are symmetric, this yields a factor 2, which is compensated by the 1 2 factor in Eq. (20). In practice, this means, for example, that flipping both interactions at once in the diagram of Eq. (51) with two "outer legs" generates a new labeled diagram.
Concretely, we translate We call subdiagrams of the types presented in Eq. (51) "caterpillar" and "watermelon". Note that the sign of the contributions changes from the second to the third order -this is different in the first Legendre transform, where also the second order contributes with a negative sign.
Fourth order One possibility to construct a fourth-order diagram using these components is to take one sub-diagram of each of the two building blocks in Eq. (51).
Because we are free also to rebuild each sub-diagram using first-order interactions, defined in Eq. (36), we have to sum up four contributions in total: We evaluate these diagrams using Eqs. (36), (50) and (51), which yields for the second diagram Evaluating the diagrams joining two second-order contributions, we obtain where the prefactor is explained as follows: The two entire subdiagrams of order 2 act as interactions so they come with a 1 2 . Analogously to the respective subdiagram in Eq. (54) (corresponding to the second square bracket), the watermelon contribution comes with a 1 2 and we have two possibilites to join the legs of the two interactions.
Along similar considerations, we evaluate the two remaining contributions, which yield In total, the sum of this group of diagrams vanishes. We will demonstrate later that this can be seen as a special case of a diagram bearing a caterpillar subdiagram, which is connected at two points to another subdiagram of a different topology. We will show that the contribution from diagrams of this kind are canceled, akin to the cancelation of contributions from two-particle reducible diagrams for expansions around Gaussian theories.
Considering pure ring diagrams, however, we observe that the contributions do not cancel out in general ‡. This is not a contradiction to the rule concerning diagrams containing caterpillar parts we foreshadowed before because for ring diagrams, the identification of the two nodes, at which the diagram is reducible and therefore decomposes in two parts, is not unique. In section 8, we shall determine the prefactor of a ring diagram of order n.
The next group of diagrams of fourth order are again watermelon diagrams, and, together with their translation, they read (63) ‡ If the integration variable is discrete, as for a graph, the sets for which some of them agree do not have vanishing measure and have to be considered separately. We will see in 6 that for these special cases, the contribution of the ring diagrams indeed vanishes if exactly one pair of indices is identical.
Here, the hatched blob associated to the second derivative of Γ 0 , unlike the first two groups of diagrams, is attached to cumulants of order higher than two at both sides. Therefore, in general, the first two diagrams are translated in a different way than the last one. However, even if all cumulants of the unperturbed theory are equal, as is the case for an ideal gas, the contributions from watermelon diagrams do not cancel. For this special case, we will determine the prefactor of a watermelon diagram of order n in section 8.
Finally, there are "glasses" diagrams (as they were christened in [11]), which are generated by both line (19) and line (20) to yield For the ideal gas, again, all of these contributions are equal and their sum therefore vanishes. Of course, in general κ y 3 κ y 3 κ y 2 = κ y 4 and therefore, this is not true for all systems. We now examine how the expansion we have set up unfolds for Ising or Potts spins living on a graph.

Translation of diagrams for Ising and Potts model
We now work with a spin system where ψ x = 0, 1, . . . , q (or ψ x = ±1 in the Ising case) and x is a node of a graph. For the diagrams up to third order and the first group of diagrams of fourth order, the evaluation of diagrams is a straightforward application using, of course, the correct expressions for the unperturbed cumulants. x =y =z =x

Ising model
which is in agreement with the first two lines of Eq. (17) in [4] (they have the opposite sign convention in the definition of the effective potential).
To fourth order, specifying Eq. (58), we have to consider three cases depending on the number of identical indices: x,y pairw. uneq.
where the prefactor in the second line is different because there are two possibilities to choose from: x = u or y = v. This contribution is canceled by the other ring contributions of fourth order, Eqs. (59) and (60). All in all, the ring contribution of fourth order is Γ Ising 4 ′ th order ring = where the plus-sign in the first line comes from the overcompensation of the contribution of the first diagram, Eq. (58) by those of the other two diagrams, Eqs. (59) and (60).
The watermelon diagrams, Eq. (63), can also be evaluated: = − 1 12 x =y The "glasses" diagrams, Eq. (65), lead to the expressions Finally, we now combine the contribution from the glasses diagrams with x = z with the contribution from the pairwise identification of opposite indices in the ring diagram,

Eq. (73) and the watermelon diagram term to obtain
Putting everything together, we obtain Γ Ising 4−th order = This exactly, and elegantly, reproduces the remaining lines of Eq. (17) in [4].

Potts model
Here, the Hamiltonian reads as The source field for every node x and the coupling for a bond xy is now a q-dimensional vector. Therefore, we have to sum not only over the nodes of the graph, but also over the flavors from 0 to q − 1 to evaluate a diagram. To do this, we obviously also have to know the expressions for the cumulants in the the uncoupled case. Here, all moments of a spin ψ x are equal and given by the value of its source field h x through and therefore These diagonal elements are sufficient to compute Γ because the interaction is diagonal in the flavor. We finally obtain By equating the derivatives of Γ Potts [φ, ∆] (or Γ Ising [φ, ∆]) with respect to φ or to ∆ to the one and two-body couplings, one directly obtains the expression we are after.

Translation into the language of simple liquids
In the case of simple liquids, the relevant degrees of freedom are the positions x i of the N particles making up the system. We may also choose to work in terms of the empirical densitŷ which depends on the continuous variable x. The average of this quantity over the particle positions yields the local density ρ (x) := ρ (x) . The densitiesρ and ρ play the role of ψ and φ in our earlier presentation. When the particles interact via a pairwise poential w and and are in addition subjected to an external potential u, the energy of the system can be expressed as a functional ofρ as The two contributions to E have the form of a one and a two-point source term forρ, respectively, so that the cumulant-generating function of the simple liquid reads, in the grand canonical ensemble with chemical potential µ, where the one-body source ν (x) = −β (u (x) − µ) now incorporates the chemical potential. In the absence of an interaction potential, denoting W 0 [ν] = W [ν, 0], we see that the statistics of the empirical density is fully known. The cumulants ofρ, for instance, are given by: In the presence of interactions, w = 0, the functional W [ν, w] can be obtained from This expression is similar in spirit to Eq. (10) (with the correspondence ψ →ρ, φ → ρ and i → x), up to the fact that here we are working directly with the cumulantgenerating function instead of with the second Legendre transform. Note that the additional δ (x − y) δ δν(x) in the exponential in Eq. (100) expresses that we exclude selfinteractions from the energy E.
This connection between the static theory of simple liquids [20,14,15] and field theory has been seldom been exploited in the past [21,22,16]. For completeness, in the appendix 11.2, we have given the proofs to the two theorems due to Goeppert-Mayer and Mayer [23] using the formalism of this chapter. The first of these two theorems, which is valid generically for systems described by Eq. (1), states that the cumulant-generating function is represented by all connected diagrams. The second Mayer theorem relies on the Poisson statistics of the ideal gas (with all cumulants Eq. (100) being equal), and it is therefore only valid for simple liquids. It states that the first Legendre transform is represented by all one-particle irreducible diagrams, that is, those that cannot be cut into two pieces by removing a node representing a single cumulant.

Effective potential for simple liquids
Combining the results of the previous sections, we have everything at hand to derive a diagrammatic expansion of the second Legendre transform in a simple liquid. This is easier to obtain than its analog in systems with a finite number of states for two reasons. First of all, all cumulants are equal in the unperturbed theory and second, the integration variables are continuous and uniform, and this waives part of the technicalities in which distinguishing equal lattice sites (as in the Ising model) was necessary.
When discussing the diagrammatics in the general case, we have identified two classes of diagrams that play an important role in simple liquids. These are the watermelon and ring diagrams. We will show that these, together with two-particle irreducible diagrams, are the only ones contributing to the expansion of the second Legendre transform (our proof is completely different from that of [14,15] but perhaps closer in spirit to that of [16]). For theories with two-body interactions, two-particle irreducible diagrams are defined by their property that, by removing two nodes, they cannot be separated either into more than two pieces or into two pieces each of which containing more than one interaction. Hence the first nontrivial diagrams to consider are the fourth-order ones.
To fourth order, we have noted that the ring and the watermelon diagram, albeit two-particle reducible, do not cancel. This is also true for their higher-order equivalents, the symmetry factors of which, S ring,n and S watermelon,n , are given by .
We now prove both of these statements by induction, assuming that for n arbitrary, but fixed, they hold for all k < n. As we have seen in the fourth order, there are several ways to construct a ring diagram of n-th order. Concretely, we can cut the ring into several pieces at any node, the only restriction being that the largest part is of order n − 2 (because, according to the general rules, subdiagrams with n − 1 interactions must not be used to construct diagrams of order n). All of these contributions yield the same expressions, only with different numerical prefactors and signs. To keep track of those, it is convenient to define an index set that we call the reduced partition P r (n) of n P r (n) = k ∈ N n−2 Let k ∈ P r (n) characterize a ring diagram of order n decomposed into k 1 pieces of length 1, k 2 pieces of order 2 and so on. There are ( i k i )! possibilities to concatenate them into a "caterpillar". Sticking the ends of it together to form a ring, we reduce this symmetry factor by an amount 1 2 i k i because we can start to concatenate at every node and we can go either clockwise or counter-clockwise. Then, taking the derivative of a ring diagram of order i+1, we obtain a caterpillar of order i bearing the prefactor (−1) i+1 because there are i + 1 pairwise correlations to differentiate, which are symmetric, hence the 1 2 is compensated as well. Combining this with the prefactor 1 k i ! for every group of caterpillars, summing up the symmetry factors of all contributions and taking the global minus sign into account, we eventually obtain By a lengthy, yet elementary calculation, we show in 11.3.1 that this expression is actually identical to Eq. (101). We proceed similary for the watermelon diagrams, in particular, we use the same partitions of n. Differentiating the contribution of order i + 1, i ≤ n − 1 with respect to ∆, we obtain, according to the induction assumption, a factor (−1) i+1 i . Besides the flipping of vertices, there are no further symmetries to Figure 2. a) The two-particle irreducible diagram of lowest order, the "tetraeder", b) with one interaction removed.
consider so that we obtain and by a calculation similar to that of the ring diagrams (details in appendix 11.3.4), we arrive at Eq. (102).
What are the other diagrams contributing to Γ? First, there are diagrams that are two-particle irreducible, which can only be built sticking M's together. These are rather rare, the first of them is of sixth order, in which four nodes are connected all-to-all by interactions (termed "tetraeder" in [16], see Figure 2). What about two-particle reducible diagrams other than those of ring or watermelon type? We can discriminate the following cases here: (i) The ∆-derivative of a two-particle irreducible subdiagram is stuck to the remainder at two nodes; (ii) One caterpillar diagram is attached to the remainder at two nodes; (iii) One watermelon diagram is attached to the remainder at two nodes.
We will prove by induction that all three contributions vanish. We can therefore assume in the following that all diagrams of lower order than the one we are constructing are either two-particle irreducible or of the ring or the watermelon type.
Considering the first case, we observe that by differentiating a two-particle irreducible diagram with respect to ∆, we obtain in general a two-particle reducible diagram. However, it is impossible that the differentiated diagram decomposes into two pieces by removing the nodes the removed interaction was attached to. Indeed, diagrammatically, this would look like , where the hatched blobs represent the remainder of the diagram and the dotted line the removed interaction. We see that if the differentiated diagram were two-particle reducible at these nodes, the original diagram would be two-particle reducible as well. This is a contradiction to our assumption. Let us consider the lowest-order two-particle irreducible diagram, shown in Figure 2, as an example to illustrate this statement: Removing any interaction from the tetraeder, we obtain a two-particle reducible diagram. Figure 3. Example of two contributions that together cancel one-particle reducible diagrams.
We might therefore fear that, besides at the two points we join the other subdiagrams, we obtain two other points at which the whole diagram can be decomponsed into two nontrivial pieces. Indeed, as shown in panel b) of Figure 2, the tetraeder with one interaction removed decomposes even into four parts by removing the other diagonal interaction (and the cumulants attached to it). However, it is exactly the interaction that is not attached to the interaction removed. During the iterative generation of diagrams, we are thus not allowed to connect any subdiagram at these places (which would add a two-particle reducible diagram in the higher order). We see with this example that the only points, at which a diagram generated during the iteration can be two-particle reducible, are exactly the joining points of the subdiagrams. Consequently, subdiagrams built from removing an interaction from a two-particle irreducible diagram can enter a diagram in only two ways: Either by using the derivative of the corresponding two-particle irreducible diagram as interaction or by rebuilding a subdiagram of the same shape with interactions M of order 1. That both of these two contributions also contribute with the same symmetry factor can be shown analogously to the proof for two-particle irreducibility of the diagrams for Γ expanded around a Gaussian theory: Building the subdiagram with M 's, the symmetry factor of the entire diagram can be determined by first choosing n + n ′ n interactions to be part of the subdiagram we assume to be of order n (the remainder being of order n ′ ). Together with the prefactor 1 (n+n ′ )! , this yields 1 n!n ′ ! , corresponding to the orders of the subdiagrams. Consequently, both ways to construct the diagram yield the same value. Because, however, the subdiagram comes with a minus sign if it is part of a ∆-derivative of Γ, the sum of these contributions cancel. As a final remark for this case, let us note that the factor 2 coming about by differentiating the two-particle irreducible subdiagram by ∆ is compensated by the factor 1 2 in front of any two-point term in the differential operator A as defined in Eq. (13).
Case (ii) is different because, similarly to the construction of ring diagrams, there is more than one possibility to create the caterpillar diagram. Assume that the caterpillar contains n > 1 interactions and the remainder n ′ . As for the ring diagrams, the caterpillars can be built from pieces representing partitions of n, with the only difference that here, all partitions are allowed. Furthermore, now both the starting point and the direction of the concatenation matter so that the sum of the symmetry factors of all of these contributions is In appendix 11.3.2, we show, by slightly adapting the calculation of appendix 11.3.1, that this expression vanishes unless n = 1. Because in caterpillars, all cumulants are of order 2, the statement that diagrams with integrated caterpillars yield vanishing contributions, holds true for all theories. It can also be used to prove that the first group of diagrams of fourth order we discussed in subsection 5.2 cancel.
For case (iii), we argue in a similar fashion; also there, the only adaptation is switching from the reduced to the full partition, this time for constructing all watermelon-subdiagrams instead of ring diagrams. The sum of the symmetry factors of all watermelon subdiagrams (which amount to multiple connections between two nodes) is then In appendix 11.3.3, we demonstrate that this expression also vanishes unless n = 1. We have therefore shown that the diagrams of cases i)-iii) indeed cancel out.
Finally, we have to prove that the same applies to all one-particle reducible diagrams. In contrast to, e.g., a Gaussian φ 4 -theory, the interaction depends onρ: M xy ∼ 1 ρxρy . Thus, each circle attached to n lines represents a quantity ∝ 1 ρ n−1 and its derivative is proportional to − (n − 1) 1 ρ n . It might seem as if an additional prefactor is introduced and therefore sticking it together with another subdiagram does not lead to the same symmetry factor as the same diagram created by interactions of order 1. However, there is yet another possibility to obtain the same subdiagram than by differentiating with respect toρ, namely removing one of the attached lines by a ∆-derivative and replacing it with a first-order interaction. Note that here, we are discussing a diagram that is composed of a subdiagram of order n attached to another diagram of order n ′ . Constructing the isolated order n diagram we would only be allowed to use subdiagrams of order n − 2. However, subdiagrams of order n − 1 contribute once this diagram is integrated into a larger one. These possibilities are depicted in Figure 3. In (b), because we have n lines to potentially replace, the diagram translates with a prefactor n. Adding both contributions, we thus obtain the prefactor 1. Because the two-particle irreducible diagram that we differentiate contributes with a minus sign, this amounts the cancellation of one-particle reducible diagrams -that the remaining symmetry factors are the same for all variants to build a diagram of a certain topology can again be argued analogously to the Gaussian case.
This completes the characterization of the diagrams contributing to Γ for the case in which the unperturbed theory is the ideal gas: They are either of the ring or the watermelon type, or they are two-particle irreducible.

Outlook
A short summary of our results is as follows: we have designed some diagrammatics to deal with perturbations around a noninteracting non-Gaussian theory, at fixed field average and correlations. This is thus a perturbative approach in powers of interactions to the inverse problem which consists in finding the couplings able to achieve these two sets of constraints on the field. The diagrammatic approach we have set up is rather powerful, as we have illustrated on two canonical systems: the Ising model (previously approached in [4]) and simple liquids (also explored by other methods in [14] in a more distant past). It is also remarkably aesthetic, in our opinion, that such distant problems as the Ising model or the ideal gas, or standard field theories, can actually be tackled with the exact same formalism. Of course, this proof of concept calls for further, yet unexplored, extensions and applications.
In terms of extensions, we have worked with a noninteracting (non-Gaussian) theory perturbed by two-point interactions. Certainly, some of these restrictions could be waived. For instance, one could work with a correlated non-Gaussian theory, as long as the correlations of the latter are available. Of course, higher-order interactions could also be considered.
In terms of physical applications, we see two interesting problems. In the theory of simple liquids the statics of the ideal gas is not described by a Gaussian theory. Dynamics-wise, the same holds: the description of the dynamics of an assembly of, say, independent Brownian particles, involves a dynamical action (Martin-Siggia-Rose-Janssen-De Dominicis) which is non-Gaussian in the density field [24]. This renders approximations based on perturbing around the ideal gas particularly cumbersome. This has for instance been illustrated in a series of papers striving to study the dynamics of the dense phase by field-theoretic methods [25,17,26,18]. With the tools presented in this work, this opens up the possibility of a perturbation expansion where the non-Gaussian theory already satisfies (exactly) a fluctuation-dissipation theorem.
Beyond glassy dynamics, where the approach would be used directly to establish an evolution equation for correlations, our tools can also be exploited for actual inference questions. We have in mind, for instance, projecting the data retrieved from the simulation of a Vicsek model [27] (or the observation of some bird flock) onto a Heisenberg model [28]. We are perfectly aware that there are other methods to achieve that goal, and that these other methods are numerically more powerful. However, our approach should be able to shed some analytical light on problems that deserve to be attacked by several methods.

Acknowledgements
We thank Michael Dick and Ulisse Ferrari for valuable feedback on the manuscript.

Generalized treatment of Gaussian theories
In the approach employed in Section 4 we do not treat the one-and two-point functions on equal footing. One could also add a two-point source term to the unperturbed theory, which we choose, together with j so as to make W 0 yield the right cumulants. Then, one ∆]] to obtain the derivatives of Γ, which yields In the respective last steps, we have used that δ 2 Γ δ∆δφ = 0 if the unperturbed theory is Gaussian. In this case, furthermore In order to evaluate Eq. (110), we furthermore have to rewrite the K-derivatives in terms of j-derivatives. This is necessary because the contributions stemming from the bare interaction are expressed in terms of those. The unperturbed theory being Gaussian, it suffices to compute the K-derivative of the first and second derivative of W 0 : Comparing Eq. (113) with Eq. (110), we observe that the terms with j-derivatives in Eq. (110) are canceled by the terms coming about by letting the K-derivative act on a first-order j-derivative (after inserting the right value of j). Therefore, Eq. (110) can be represented by a diagram with two external legs. Now, using Eqs. (111) and (112), we have reproduced the result of the main text, namely that a φ-derivative corresponds to removing a dangling leg and a ∆-derivative to the removal of a propagator line. Consequently, also the result that only two-particle irreducible diagrams contribute to the expansion of Γ int is reproduced. In principle, one could generalize our result to general non-Gaussian theories in this way. However, this is harder to to do than it is for the first Legendre transform because in this case δ 2 Γ 0 δφδ∆ = 0 in general and therefore, Eqs. (111) and (112) do not hold anymore.

Proving Mayers' theorems
11.2.1. First Mayer theorem Loosely following the proof presented in [11, appendix 3] and adapting it to the language of simple liquids, we will demonstrate that W is represented by all connected diagrams, which is known as the first Mayer theorem. Splitting the cumulant-generating function into a solvable and a perturbing part as W = W 0 + W V , we rewrite (100) as Assume now that we apply the perturbing part only l ≤ L times and, accordingly, define where we have abbreviated Then we clearly have that and therefore This tells us that we obtain the contributions of order l + 1 to the cumulant-generating function by binding together lower-order ones by an interaction. Diagrammatically this means that we connect an interaction vertex to lower-order contributions, including W 0 . As in the case of the effective potential discussed in the main text, at every iteration step, at most one interaction survives the L → +∞ limit.

Resummations for simple liquids
We can exploit the perturbation expansion of the simple liquid to perform partial resummations. Consider the sum of all watermelon diagrams: Their symmetry factors are rather easy to determine: in the diagram of order n, n − 1 vertex flips generate a new labeled diagram, so that one factor 1 2 remains and in total the prefactor reads 1 2 1 n! . The cumulants of the unperturbed theory being identical, we can resum these contributions, obtaining where f is known as Mayer function. What is now left to be shown is that we can perform this resummation also with diagrams with more than two nodes. We therefore conjecture that we obtain the full perturbation expansion of Γ 1 by the following rules: (i) Draw all one-particle irreducible diagrams with each pair of nodes connected by at most one interaction line (ii) Determine the symmetry factor of the diagram as usual (iii) Assign a factor f (x, y) to a line connecting nodes representing the densities ρ (x) and ρ (y) and integrate over all variables.
First, consider an interaction edge that is distinguished in the topology of a given diagram, like the one connecting the opposite nodes in (120) Assume that in the remainder of the diagram, with the symmetry factor S rest , there are k rest interactions. We replace the distinguished interaction by a k-fold interaction, which yields a new diagram with the prefactor coming about because we have k + k rest k possibilities to pick k out of k + k rest interactions to be part of the k-fold connection. Therefore, the only difference between the prefactor of the enhanced diagram to that of the original one is indeed 1/k!. Most interactions, however, are not topologically distinguished in a given diagram. By replacing one of them by a k-fold interaction, we distinguish it from the others and therefore, we potentially change the symmetry factor of the whole diagram. We have to make sure that this does not spoil the possibility of a resummation of interactions in Mayer functions. Assume that we have N equivalent interactions (like the four outer interactions in (120)). We now choose an arbitrary partition i N i = N of this number and replace N i of the interaction lines by k i -fold ones (with k i = 1, 2, . . .). Now, the prefactor of this (part of the) diagram is given by because we have i k i N i k 1 possibilities to choose interactions for the first group of multiple connections, for the second (if N 1 > 1) and so on.
Because we have N i equivalent spots for interactions with k i -fold interactions, we have to divide this expression by N i ! in addition. Let's show that this yields the same expression as using the rules with the resummed interactions. To this end, using the extended diagrammatic rule conjectured before, we insert the resummation Eq. (119) into the expression for the diagram with single interactions, which bears 1 N ! as prefactor because the diagram without resummations contains N interactions. Multiplying out the product of the series expansions of the exponential functions, we observe that there are N ! i N i ! possibilities to choose N i monomials with degree k i out of N factors for all i. The factor 1 i (k i !) N i is contained in the definition of the exponential function. We therefore recover the same prefactor Eq. (121) by applying the foreshadowed rules as by resumming the original diagrams. This completes the proof that we can replace the standard diagrammatic rules by (i)-(iii). Because multiple connecting lines do not occur here, interactions are normally represented by straight lines in the simpleliquids literature; we, however, do not stick to this convention to avoid confusion with propagator lines of Gaussian theories.

Second Mayer theorem
Now, we change our variable to describe the system's state: We do not use the source term (or single-particle potential) ν, but its conjugate variable, the (local) density ρ, by using the (first) Legendre transform to define To derive its diagrammatic representation, we proceed as for the cumulant-generating functional, that is we write where This is a special case of Eq. (12) in [11], with j and x relabeled as ν and ρ, respectively. Note that there, summations over indices and integration over continuous variables are implied (here we made this explicit by writing out the integrals over the positions of the particles). Constructing the diagrams, we can now argue exactly as in [11], up to the fact that, in the present case, all cumulants of the unperturbed theory, (100), are equal. Therefore, we do not need to use the relation Γ V [ρ] = −g Γ (1) 0 [ν] to determine the derivative of Γ V , but we can evaluate it directly: δ δρ Γ int 1 is represented by all diagrams of Γ int 1 with one node removed in every possible way. Computing the symmetry factor of the entire diagram, we argue as in the Gaussian case that diagrams of a given shape always bear the same symmetry factor, no matter if they were generated by (123) or (124) -however, they occur with opposite signs. Therefore, in a way similar to perturbations around Gaussian theories, all diagrams that decompose into two pieces by removing a cumulant get canceled: only one-particle irreducible diagrams remain, which is known as second Mayer theorem. This is a peculiarity that the unperturbed Poisson and Gaussian distributions share in common (for other non-Gaussian theories, a new class of diagrams would have to be introduced for the first Legendre transform [11]). 11.3. Some identities needed for the diagrammatic expansion of the simple liquid 11.3.1. For isolated ring diagrams For the construction of ring diagrams, we need the following identity: where P r (n) is defined in Eq. (103). In (126), we have extended the range of the k-sum from P r (n) to P (n). This is possible because it only adds the entries with k 1 = k n−1 = 1, k i = 0 ∀i = 1, n − 1 and k n = 1, k i = ∀i = n, yielding contributions 1 and −1 in (125), so they cancel. We can go a step further and let the dimension of k tend to infinity because k i will be 0 automatically for i > n: We multiply (128) with z n (with z ∈ R, |z| < 1) and sum n from 1 to ∞: We represent the factorial of the sum as ( m i=1 k i − 1)! = ∞ 0 e −u u m i=1 k i −1 du. This integral expression can also be written down for m i=1 k i = 0 so that we can lift the remaining restriction on the k-sum and instead substract the contribution for m i=1 k i = 0: We use that, because |z| < 1, lim m→∞ Together with Z r (0) = 0 = ln (1 + 0) and d dz ln (1 + z) = 1 1+z , this proves that Z r (z) = ln (1 + z) = ∞ n=1 (−1) n+1 1 n .
So, by comparing the coefficients of n, we obtain the desired result, Eq. (125).

11.3.2.
For caterpillars integrated in two-particle reducible diagrams We now would like to derive that The only difference to the claim in the preceeding section is the factor ( n i=1 k i )! replacing ( n i=1 k i − 1)!. Therefore, we just have to remove the 1 u in Eq. (131) and the following ones, in particular Eq. (137) to obtain for the corresponding partition function so all coefficients of P rc (z) but the linear one vanish.
11.3.3. For multiple connections in two-particle reducible diagrams We would like to demonstrate that With the same trick as in 11.3.1, i.e. multiplying by z n , summing over n from 1 to ∞, exchanging the order of summation, performing the sum over n and finally adding and deducing the contribution from m i=1 k i = 0 (which yields 1), we obtain for |z| < 1 We use m