Resource engines

,


Introduction
Thermodynamics occupies a distinguished place among physical theories: it permeates all other fields and finds applicability everywhere, from astrophysics [1] and biophysics [2] to condensed matter [3] and physics of computation [4].The reason for this is that thermodynamics actually forms a meta-theory that employs statistical reasoning to tell us which state transformations are allowed, and which are probabilistically impossible.In other words, thermodynamics can be seen as a field studying the accessibility and inaccessibility of one physical state from another [5], abstracting away whether these states describe electromagnetic radiation, a gas of spin particles or electrons in an atom.
This perspective inspired the development of quantum resource theories [6], where one investigates allowed Hanna Wojewódka-Ściążko: hanna.wojewodka@us.edu.pltransformations between quantum states under general, not necessarily thermodynamic, constraints.The bestknown example is given by the theory of entanglement [7], where bipartite system transformations are constrained to local operations and classical communication, and one is interested in the possible manipulations of entangled states.Other widely studied examples include state transformations under operations that are incoherent [8], symmetric [9] or Clifford [10].In all these theories, clear parallels with thermodynamic considerations have been made.Similarly as every thermodynamic transition can be made possible by investing enough work, universal resources in other theories (such as ebits [11], refbits [12] or coherent bits [13]) have also been identified and their optimal manipulations have been investigated.Also, the thermodynamic concept of catalysis was extended to general resource theories, where catalysts are given by ancillary systems that make otherwise forbidden transitions possible, while being unchanged in the process [14,15].Finally, probably the most important link between thermodynamics and other resource theories is through the second law of thermodynamics [16], where general resource monotones [17], such as entropy of entanglement [7] or relative entropy of coherence [8], play the role of monotonically decreasing thermodynamic free energy, and the questions concerning reversibility and irreversibility of a given resource theory are central to the field [18][19][20][21].
Given how fruitful the thermodynamic inspirations have been so far for quantum resource theories, in this paper we aim at pushing this analogy one step further.So far most of such inspirations have been based on thermodynamic considerations concerning scenarios with a single heat bath.Notable exception is given by the resource theory thermodynamics itself, where the efficiency and performance of quantum heat engines [22][23][24] and more general autonomous thermal machines [25,26] working between two baths at different temperatures were studied from a resource-theoretic perspective.However, the approach to general resource theories neglects this very important part of thermodynamics with access to two heat baths.It is true that, from a purely resource-theoretic perspective, having access to two infinite baths at different temperatures in some sense trivialises the theory, as one can then perform infinite amount of work, and so every state transformation becomes possible (at least in the semi-classical regime of energy-incoherent states [27]).
However, the physics of heat engines is far from being trivial, one just needs to ask different questions.Instead of looking for the amount of work that can be extracted from a given non-equilibrium state, one rather asks about the optimal efficiency of converting heat into work, or about the maximum power of a heat engine.
We thus propose to investigate the performance of resource engines, which generalise the concept of heat engines by replacing the access to two heat baths at different temperatures with two arbitrary constraints on state transformations.More precisely, we consider two agents (traditionally refereed to as Alice and Bob), each of which is facing a different constraint, meaning that each of them can only prepare a subset of free states, F A and F B , and can only perform quantum operations from a subset of free operations, F A and F B .Now, the idea is to imitate the action of a two-stroke heat engine: instead of subsequently connecting the system to the hot and cold bath, it is sent to Alice and Bob in turns and they can perform any operation on it from their constrained sets F A and F B .Since the free states and operations of Alice will generally be resourceful with respect to Bob's constraints (and vice versa), a number of such communication rounds with local constrained operations (i.e., strokes of a resource engine) may generate quantum states outside of F A and F B .Thus, by fusing two resource theories described by (F A , F A ) and (F B , F B ), one can obtain a new resource theory with free operations F AB ⊇ F A ∪F B and free states A number of natural questions then arise.First, can a resource engine defined by given two constraints generate a full set of quantum operations, or at least approach every element of this set arbitrarily well with the number of strokes going to infinity?Alternatively, can it achieve all possible final states starting from states belonging to F A or F B ?If the answer to these questions is yes, then can we bound the number of strokes needed to generate every operation or state?And if there exists a state that is maximally resourceful with respect to both Alice's and Bob's constraints, what is the minimal number of strokes needed to create it?Note that given that each stroke takes a fixed amount of time, this effectively corresponds to studying the optimal power of a resource engine.One can also ask about the equivalent of engine's efficiency.Namely, whenever Bob gets a state from Alice and transforms it using an operation from F B , he necessarily decreases the resource content of the state with respect to his constraint, but may increase it with respect to Alice's constraint.Thus, one may investigate the optimal trade-off, i.e., the efficiency of transforming his resource into Alice's resource.
In this paper, we start with our resource-theoretic perspective on standard heat engines in Sec. 2, where Alice and Bob are constrained to having access to heat baths at different temperatures.More precisely, in Sec.2.1, we recall the necessary notions of thermal operations and thermomajorisation, set the notation, and formally state the main problems of athermality engines we want to investigate.Next, in Sec.2.2, we fully solve these problems for an elementary example of a two-level system.Section 2.3 contains our main results for athermality engines with arbitrary d-dimensional systems, where we lower and upper bound the set of achievable states F AB , as well as find its exact form in the limit of the hotter bath having infinite temperature.We then proceed to Sec. 3 that is devoted to the concept of unitary coherence engines, where Alice and Bob are constrained to only performing unitary operations diagonal in their fixed bases, so that coherence with respect to these bases is a resource for them.First, in Sec.3.1, we set the scene by recalling the necessary formalism, fixing the notation and stating the problems.Next, as in the athermality case, we fully solve these problems for the simplest case of a two-level system in Sec.3.2.In Sec.3.3, we then derive and discuss the conditions under which the full set of unitary operations can be performed jointly by Alice and Bob, i.e., when F AB becomes the full set of unitary operations.We analyse the number of strokes N needed to get all these operations in Sec.3.4, presenting both lower and upper bounds for N .Finally, in Sec.3.5, we discuss the problem of using the resource engine to produce a state that is simultaneously maximally resourceful for both Alice and Bob.We end the paper in Sec. 4, where we discuss relations between resource engines and known problems within quantum information, and outline opportunities for future research.

Athermality engine 2.1 Setting the scene
In the resource-theoretic approach to thermodynamics [28], one assumes there is a single agent A that has access to a thermal heat bath at inverse temperature α = 1/(kT A ), with k denoting the Boltzmann constant, and is allowed to unitarily couple the system of interest to the bath in an energy-conserving way.More formally, given a quantum system in a state ρ and described by a Hamiltonian H, the set of operations F A that the agent can perform consists of thermal operations E with respect to α defined by [28,29] where is a thermal Gibbs state of the environment described by an arbitrary Hamiltonian H E , and U is a joint systembath unitary preserving the total energy, i.e., ( The central question is then given by the following interconversion problem: which final states σ are achievable from a given initial state ρ via thermal operations?Note that the only free state that any state can be mapped to is the system's thermal Gibbs state γ (defined by Eq. ( 2) with H E replaced by H), and all other states are treated as resources.In other words, the free set F A consists of a single element γ.
Here, we will focus on the quasi-classical version of the interconversion problem with initial and final states of the system commuting with γ.This case is usually referred to as incoherent thermodynamics, since one then focuses on interconversion between states that do not have quantum coherence between different energy eigensectors.Instead of representing quantum states as density matrices of size d, one can then use a simpler representation using d-dimensional probability distributions describing occupations of different energy levels.We will thus denote the initial, final and Gibbs states by probability vectors p, q and γ, respectively.
The main reason why we restrict to the incoherent setting is because then the necessary and sufficient conditions for the existence of a thermal operation mapping p to q are known to be fully characterised by a thermomajorisation condition p ≻ γ q [28] (also known as d-majorisation [30]).For a full review of this subject, we refer the reader to Ref. [31], while in Appendix A we summarise the bits of the theory necessary for our purposes.Here, we only note that a thermomajorisation curve (also known as the Lorenz curve) of p with respect to γ is a piece-wise linear and concave curve on a plane starting at the origin and consisting of segments with the horizontal x length given by γ i and vertical y lengths given by p i (note that concavity of the curve enforces a particular ordering of these segments).Then, we say that p thermomajorises q, p ≻ γ q, if and only if the thermomajorisation curve of p lies above that of q everywhere.Now, our aim is to study a modified setting with two agents, A and B, that can exchange the processed system between each other, and with each of the agents being constrained to only performing thermal operation with respect to their (unequal) temperatures 1 .More precisely, we consider the set of free operations F A to be given by thermal operations with inverse temperature α and the corresponding free state given by γ with where {E i } denotes the energy levels of the system; and the free set of operations F B to be given by thermal operations with inverse temperature β < α and the corresponding free state given by Γ with The main question that we will investigate is: what is the resulting set F AB of achievable states if each of the agents is constrained to their own set of free states and operations (so that together they can generate any operation from the set F AB )?In other words, we look for all states p (N −1) (and their convex combinations via randomised strategies) that can be obtained via a sequence of thermomajorisations either from γ or Γ, i.e., that satisfy one of the following: for a given value of N (set of states F (N ) AB achievable after N strokes) or for N → ∞ (set F AB of all achievable states).Note that in the investigated setting we assume that the agents exchange the total system that is fixed, so that all ancillary systems (like a battery) need to be explicitly modelled and the system's Hilbert space does not change.More generally, once the free set F AB resulting from fusing two resource theories is known, one can also investigate allowed resource transformations in this new theory.In other words, on can ask what final states can be achieved via F AB when the initial state is outside of F AB .

Elementary qubit example
We start with the simplest case of a two-level system that will serve us as an example to illustrate problems at hand.The two thermal states are then simply given by with γ ≥ Γ.In what follows, we will denote a thermal state by g = (g, 1 − g), without specifying whether g = γ or g = Γ.The set of all states achievable from a given state p via thermal operations (i.e., the set of states q such that p ≻ g q) is convex and its extremal points have been characterised in Ref. [32] by studying the thermomajorisation order (see Lemma 12 therein).For d = 2, there are just two extremal states achievable from p: the state p itself and Importantly, applying two such non-trivial extremal transformations Π g in a row with respect to the same g does not produce an extremal point.It is thus clear that the extremal states achievable from p by two agents after N = 2m + k strokes will have one of the following two forms with k ∈ {0, 1} and m ∈ N. We then note that the fixed points of the composition of extremal maps are given by (see Fig. 1a):

Note that
so that the fixed points can be mapped between each other by setting k = 1 in Eq. (9).Moreover, it is a straightforward calculation to show that as m grows, these fixed points are approached exponentially in m inside the probability simplex, always from the side of the initial point as illustrated in Figs.1b-1c.More precisely, for every p = (p, 1 − p) and m we have which allows one to completely characterise the set F (N ) AB of states achievable after N strokes.Given all of the above, it is then clear that when the initial state p belongs to (14) then the set of achievable states after arbitrarily large number of strokes is given by F AB .On the other hand, if p / ∈ F AB then there are two cases.If p is closer to γ in total variation distance than it is to Γ, then the set of achievable states is given by Otherwise, it is given by R γ (p) = {r : r = (1−λ)p+λΠ γ p with 0 ≤ λ ≤ 1}. ( 16) Since both sets of original free states, F A = {γ} and F B = {Γ}, are subsets of F AB , we see that starting from either γ or Γ one can achieve any state belonging to F AB .We thus conclude that F AB can be interpreted as the free set of the new resource theory that arises from fusing two resource theories of quantum thermodynamics with different temperatures.Moreover, any state p outside F AB can be considered as a resource and its transformations are governed by Eqs.(15)-( 16), which can be used to rigorously order states according to their resourcefulness.Finally, we want to emphasise that unless Γ = 1/2 (which corresponds to the hot bath being at infinite temperature), the set F AB is not a full probability simplex.This means that fusing two thermodynamic resource theories results in a new non-trivial resource theory.

Bounding the set of achievable qudit states
Beyond the simple qubit case, the problem of fully characterising the set of achievable states F AB quickly becomes intractable due to the scaling of the number of conditions one needs to verify.More precisely, during one stroke, a given initial state p can be generally transformed to d! − 1 other extremal states [32].Each of these states can then itself be an initial state of a system during the subsequent stroke, and so we see that, as the number N of strokes grows, the number of states one needs to consider explodes as (d! − 1) N .Numerically, one can reduce the number of extremal states that need to be tracked by taking their convex hull after each stroke, and keeping only the extremal points thereof.This allows us to numerically consider large N for d ∈ {3, 4}, as we later discuss.
However, we would also like to get some analytic insight into the set of states F AB achievable with the considered resource engine.Thus, in this section we first prove that there is an upper bound on F AB , i.e., no matter how many strokes N we allow for, there exist states that cannot be produced by a resource engine.Then, we provide an analytically simple construction of the lower bound of F AB , i.e., we characterise a polytope of states that forms a subset of F AB .Finally, we prove that for one bath with finite temperature and the other in the limit of infinite temperature, α > 0 and β = 0, the full set of states becomes achievable, i.e., F AB is the whole probability simplex.

Upper bound
In this section we will generalise the qubit result, showing that the set of free states F AB for a resource theory arising from fusing two resource theories of thermodynamics with different temperatures is generally a proper subset of the probability simplex.To achieve this, we will prove the following slightly more general theorem that constrains the possible final populations of the highest excited state under transformations F AB .Theorem 1.Given an initial incoherent state p and a set of operations F AB arising from fusing two resource theories of thermodynamics with different temperatures, all achievable final states q satisfy with Γ denoting the thermal state of the system with respect to the higher temperature.Thus, M (p) is a monotone of the resulting resource theory.
Proof.We start by introducing the following notation.
For a set of d-dimensional incoherent states X and a thermal state γ, we denote by T γ (X) a convex hull of all states that can be obtained from the elements of X via thermal operations with a thermal state γ, i.e., We will use analogous notation for the thermal state given by Γ.Moreover, for any incoherent state p, we denote by p its version transformed in the following way: The crucial thing about this transformation is that which is a simple consequence of the thermomajorisation order (see Appendix B for details).With the introduced notation, it is then clear that: where, for brevity, single-element sets {p} and { p} are denoted by p and p, respectively.Using the definition of thermomajorisation, one can also show for d ≥ 3 that (see Appendix B for details): for g given by either γ or Γ.Using Eqs.(21a)-(21b) and (22a)-(22b), we can now upper bound the final population q d of the highest energy level after arbitrary one sequential interaction with two baths: Since after one sequential interaction the final population of the highest energy level is bounded by either the initial population of this level or by a constant, we conclude that the same bound holds after arbitrarily many repetitions (strokes).
Using the above theorem it is then straightforward to prove the following.
Corollary 2 (Upper bound on F AB ).The set F AB of free states arising from fusing two resource theories of thermodynamics with two different temperatures is bounded by where Γ denotes the thermal state corresponding to higher temperature.
As a final remark note that, as in the two-level case, when Γ corresponds to a thermal state in the infinite temperature limit, the above bound trivialises.As we will show later, in this limit all states belong to F AB .

Lower bound
In this section we first present a simple analytical construction of a subset of the full set of achievable states F AB for a resource theory arising from fusing two resource theories of thermodynamics with different temperatures.It is based on an iterative application of the modified qubit construction we saw in Sec.2.2.We then also prove that, when the temperatures of the cold and hot bath satisfy certain conditions, F AB contains nonfull-rank states, i.e., the athermality engine can reduce the rank of the initial full-rank thermal state.In particular, we will show when this rank reduction can be maximal, by proving when the ground state belongs to F AB .
We start by introducing a d-dimensional generalisations of the states γ and Γ from Eqs. (10a)-(10b).We define them by setting one component as follows, and leaving the remaining components proportional to thermal distribution: We then have the following simple lemma, the proof of which can be found in Appendix C.
Lemma 3.For d-dimensional probability distributions p and q satisfying there exist p ′ , p ′′ , q ′ , q ′′ such that and We can now employ the above lemma to prove that the set of achievable states F AB contains both γ and Γ. Proposition 4. The set F AB of free states arising from fusing two resource theories of thermodynamics with two different temperatures contains the states γ and Γ.Moreover, the convergence to these states with the number of strokes N is exponential.
Proof.We will only prove Γ ∈ F AB , as the proof of γ ∈ F AB proceeds analogously.The proof is simply based on applying Lemma 3 iteratively m times.Starting with the hot thermal state Γ (preparation of which uses one stroke), we then apply the lemma m times, which uses 2m strokes (since each application uses one connection with the cold and one with the hot bath).By a simple application of the recurrence formula, after N = 2m + 1 strokes, one generates a state q with and the remaining components can be thermalised with the hot bath, so that for k ̸ = d: Clearly, as N → ∞, we get that q → Γ, with the convergence being exponential in m, so also with N .
Finally, we can use the above proposition iteratively to produce a whole polytope of states belonging to F AB .

Proposition 5 (Lower bound on F AB ). Within a simplex of d-dimensional probability distributions, consider a polytope P
where Then, the set F AB of free states arising from fusing two resource theories of thermodynamics with two different temperatures contains P d .
Proof.Since the set F AB is convex, we only need to show that F AB contains f b for any choice of the bit string b.
Let us then fix b and note that g In Fig. 2, we present how this lower bound (and the upper bound from the previous section) compares with the full set of achievable states F AB obtained numerically for two examples of three-and four-level athermality engines.As can be seen, in the first case, the numerically obtained F AB contains only full rank states; whereas in the second case, up to numerical precision, F AB seems to contain the rank-1 ground state.Since the pairs of cold and hot temperatures in the two studied examples were different, one may wonder whether the ability of the athermality engine to reduce rank depends on the temperature difference.In the next section we will see that, irrespective of the cold bath, when the hot bath is at infinite temperature, F AB contains all states (so also the ones with the reduced rank).Here, we show that even if the temperature of the hot bath is not infinite, but it is large enough and the cold bath is cold enough, F AB contains a rank-1 ground state (see Appendix D for the proof of the following proposition).
Proposition 6. Assume α to be large enough and β to be small enough, so that Then, the set F AB of free states arising from fusing two resource theories of thermodynamics with two different temperatures contains the ground state.Achieving this state requires N → ∞ strokes.

Full set of achievable states for β = 0
The upper bound constraining the set F AB from Corollary 2 becomes trivial when β = 0, i.e., when the hot bath is at infinite temperature.One can then wonder, whether this bound is not tight, or rather in this special case there are no constraints and the set F AB coincides with the full probability simplex.The following theorem shows that the latter is the case.

Theorem 7.
The set F AB of free states arising from fusing two resource theories of thermodynamics, one with finite and the other with infinite temperature, is given by the full probability simplex.Moreover, the convergence to the full simplex with the number of strokes N is exponential.
We thus see that the set F AB of achievable states trivialises when the hot temperature is infinite (β = 0), even without cold temperature being zero.One can see this even without analysing the formal proof.Indeed, it suffices to observe the following.Firstly, in the case of β = 0, the state γ given by Eq. (25a), is the ground state (1, 0, 0, . . ., 0).Secondly, γ belongs to F AB due to Proposition 4. Thirdly, for β = 0 the set F B contains permutations, and so Bob can transform the ground state to the highest excited state.Finally, since this state, independently of α and β, thermomajorises all other states, one can transform it to any state within the probability simplex.

Coherence engine 3.1 Setting the scene
We now depart from athermality engines and switch to investigating engines fueled by the resource of quantum coherence.The theoretical framework established to quantify the amount of coherence present in a state of the system is known under the collective name of resource theories of coherence [8,33].Their aim is to quantitatively capture the departure from principles of classical physics due to the quantum superposition principle or, in other words, to quantify the ability of a system to undergo quantum interference effects.As with every resource theory, they are defined by identifying the set of free states and free operations.While all such theories agree on the form of the free states (they are simply given by states diagonal in the distinguished basis), there are plenty of choices for the set of free operations (see Ref. [34] for a review on this subject).To avoid making any specific choices (and also for simplicity), here we will restrict our considerations to a reversible subtheory, where all different resource theories of coherence coincide.Namely, we will only consider unitary transformations, and so the set of free operations will be given by unitaries diagonal in the distinguished basis2 .To make things even simpler, in our toy theory of coherence engines we will restrict ourselves to pure states.Thus, the only free states of the theory will be given by the distinguished basis states.
More formally, we consider two agents, A and B, that can prepare the following sets of free states where U ∈ U d (C) is a fixed unitary of order d ≥ 2 over the field C describing the relative orientation of the two bases.To define the sets of free operations, let denote the subgroup of U d (C) consisting of unitary matrices diagonal in the computational basis.Now, the sets of free operations are given by Note that this setup is directly connected to the problem of Hamiltonian control [35].More precisely, one can imagine having control over a quantum system with an intrinsic Hamiltonian H 1 , and being able to change it at will to H 2 by some external influence.By carefully choosing the timings and lengths of such interventions, one can then perform a sequence of unitaries e iH1t1 , e iH2t2 , . . . .Under the assumption of incommensurable spectra, this is then equivalent to a sequence of arbitrary unitaries diagonal in two different bases (of eigenstates of H 1 and H 2 ), which is the action of a coherence engine.To give a simple example, consider a spin-1/2 system, initially prepared in an up state along the ẑ axis, and two agents, A and B, who can turn on and off the magnetic field along the ẑ and n axis, respectively.Such control of the magnetic field means that they can rotate the state of the system on the Bloch sphere around these axes.The aim is to have full control of the system's state, i.e., to have a protocol that maps the initial state to any state |ψ⟩, optimally with as few steps as possible.The introduced coherence engine formalism allows to address exactly this problem and to answer whether such a full control is possible and, if so, what is the minimal number of steps needed.
The concept of coherence engines also bears resemblance to the problem of generating universal gate sets in quantum computing [36,37].However, there are crucial differences that distinguish the two concepts.Universal gate sets in quantum computing refer to finite sets of quantum gates that, when combined in various ways, can be used to approximate any unitary operation on a quantum computer.These gate sets are typically fixed and predetermined, e.g., all single-qubit gates along with a two-qubit entangling gate (like a CNOT gate).The ability to approximate any unitary operation using these gates is a fundamental requirement for the construction of a quantum computer.On the other hand, coherence engines, while sharing some similarities in terms of their ability to implement general unitary transformations, offer a more flexible and continuous approach.Specifically, two parties can implement any diagonal unitary in two different bases, thus enabling the realization of a continuous set of operations.In the case when the bases are appropriately chosen, the two parties can also approximate any unitary, just like in the case with a universal gate set.The continuous spectrum of operations may give more flexibility, but the number of uses/strokes strongly depends on the "angle" between Alice's and Bob's bases.Therefore, it is difficult to determine whether the universal gate set or a coherence engine will give a smaller number of usages to obtain a desired approximation of a general unitary.
Similarly as in the case of athermality engines, fus-ing two resource theories described by (F A , F A ) and

Elementary qubit example
For the qubit case, it will be convenient to use the Bloch sphere representation of a pure state |ψ⟩: where r = (r x , r y , r z ) is the Bloch vector satisfying r 2 x + r 2 y + r 2 z = 1, and σ = (σ x , σ y , σ z ) is a vector of Pauli matrices.Let us also recall that an arbitrary single qubit unitary operator can be written in the form and its action on the Bloch vector r is to rotate it by an angle θ around an axis specified by a three-dimensional unit vector n.
Without loss of generality, we can then choose Alice's distinguished basis to be given by the eigenstates of σ z , and Bob's to be given by the eigenstates of n • σ with n = (sin(α), 0, cos(α)).Thus, the set F A consists of states corresponding to the north and south pole of the Bloch sphere, whereas F A is given by rotations R ẑ (θ) around the z axis by an arbitrary angle θ.Similarly, the set F B consists of states from F A rotated in the xz plane of the Bloch sphere by an angle α, whereas F B is given by rotations R n(θ) around the axis n, i.e., around the axis tilted with respect to the z axis by an angle α (see Fig. 3).
Using the Euler angles decomposition, we see that a rotation around any axis m by any angle θ can be written as where ẑ⊥ denotes a unit vector perpendicular to ẑ, and an appropriate choice of β, δ ∈ [0, 2π] and γ ∈ [0, π] has to be made.Therefore, if n = ẑ⊥ (i.e., α = π/2), Alice and Bob only need to perform three operations alternately (three strokes of a resource engine are needed) to generate arbitrary unitary operation.In other words, if the two distinguished bases are mutually unbiased (and so coherences with respect to them form complementary resources), then any unitary transformation can be generated with three strokes of a coherence engine.
Whenever n ̸ = ẑ⊥ (i.e., α < π/2), the number of strokes increases to ⌈π/α⌉ + 1.This fact, although studied in a different context, has been established, e.g., in Refs.[38,39]; cf. also Ref. [40].Indeed, the first and the last operation in Eq. (42) remain the same, but R ẑ⊥ (γ) has to be replaced by a product of alternated rotations around vectors ẑ and n, respectively.In order to justify that it is possible, as well as to estimate the number of necessary alternated rotations, let us again refer to Eq. (42), and observe that for any θ ∈ R, there exist some β, δ ∈ [0, 2π] and γ ∈ [0, π], depending on both θ and α, such that As a consequence, we get However, it is important to observe that Eq. (44) only holds for these values γ which satisfy Eq. ( 43) with certain β, δ, θ.Intuitively, the smaller the angle α between the vectors ẑ and n, the smaller the angle γ, by which we can rotate around the vector ẑ⊥ (see Fig. 3).To be more precise, γ cannot be greater than 2α.This indicates that to generate R ẑ⊥ (γ) for an arbitrarily big γ, we need to perform k rotations around ẑ⊥ by angles not bigger than 2α in a row, namely This, in turn, implies that k = ⌈γ/(2α)⌉.Since we aim to estimate the number of necessary rotations to generate any unitary matrix, we have to consider the worst case scenario, which is k = ⌈π/(2α)⌉.Note that, after applying Eq. (44) k times (with γ i , β i , θ i , δ i in the places of γ, β, θ, δ, respectively), we end up with which, due to Eq. ( 42), finally implies Therefore, the total number of alternated operations from F A and F B needed to generate an arbitrary unitary operation is equal to 2k + 1 = 2⌈π/(2α)⌉ + 1 ≥ ⌈π/α⌉ + 1.
For details of this reasoning, see, e.g., Ref. [40].An even more precise analysis, approaching the problem from the perspective of Lie algebras, is presented in Refs.[38] and [39], and the result obtained there is precisely ⌈π/α⌉ + 1.We conclude that the incompatibility of the two bases measured by α quantifies the power of a coherence engine.The analysis to estimate the number of strokes of a resource engine needed to reach any state when starting from a free state (to focus attention -an element of F A ) is very similar.The only crucial difference is that we can now choose to start from this pole of the Bloch sphere that is closer to the final state, and we do not need the initial rotation around ẑ (since states from F A are anyway invariant under such transformations).As a consequence, it is enough to select γ in Eq. ( 42) from [0, π/2] (instead of [0, π]), which requires ⌈π/2α⌉ strokes.This allows Alice and Bob to create a state with arbitrary polar angle, and the final rotation around ẑ allows for the choice of arbitrary azimuthal angle, thus getting to all states on the Bloch sphere.In conclusion, being restricted to the sets F A , F B of their free states and F A , F B of their free operations, Alice and Bob can reach any pure quantum state with ⌈π/2α⌉ + 1 strokes of a resource engine.
Instead of asking how many strokes it takes to get any state (or operation), we can also try to determine what is achievable with just three strokes, i.e., one round of communication between Alice and Bob.In particular, we will be interested in the conditions under which they can generate an optimal state (for both Alice and Bob) in this way.Of course, we first need to define what we mean by optimal in this case.It is natural to see the optimal state as the one that is maximally resourceful for both parties, and as such we can choose a maximally mutually coherent state with respect to Alice's and Bob's bases (see Appendix E or Refs.[41][42][43]).For two qubit bases given by eigenstates of m•σ and n•σ, a maximally mutually coherent state is given by a state with a Bloch vector r ∝ m × n, where × denotes the cross product.Thus, in our case with m = ẑ and n = (sin(α), 0, cos(α)), it is an eigenstate of σ y , which corresponds to a state described by a Bloch vector with the polar angle π/2 and the azimuthal angle π/2.Now, note that the first stroke just prepares one of the two states from F A , and the third stroke is an operation from F A that cannot change the polar angle of a state.We thus see that in order to create the optimal state in three strokes, an operation from F B must transform the polar angle of the state from F A (with polar angles 0 or π) to π/2.Since a rotation around an axis tilted by α with respect to the initial Bloch vector can at most create an angle 2α between the initial and final vectors, we see that this is possible if and only if α ∈ π 4 , 3π 4 .Therefore, as long as the largest absolute value of the overlap between the distinguished basis states is smaller or equal than cos(π/8), a coherence engine can produce a maximally mutually resourceful state in just three strokes.For a step-by-step analytical proof of the presented argument, see Appendix E.

Condition on getting all operations
For the elementary case of a qubit system, we have seen that, as long as the distinguished bases of Alice and Bob do not coincide, a coherence engine can generate an arbitrary unitary operation.For higher-dimensional systems, however, this is no longer the case.Thus, the aim of this section is to formulate conditions under which Alice and Bob, restricted to performing operations from F A and F B , respectively, are able to generate an arbitrary unitary.In other words, we ask under what conditions F AB becomes the full set of unitary operations.
For a given U ∈ U d (C), let us introduce a matrix i,j=1 over the field R + , which corresponds to U in the following sense: Next, let us formulate the following two conditions on a matrix U ∈ U d (C): (H1) There exist a constant M ∈ N and matrices is a matrix with all non-zero entries.
(H2) There exists a constant M ∈ N such that is a matrix with all non-zero entries.
Obviously, hypothesis (H2) is much easier to verify in practise than hypothesis (H1).However, in Appendix F, we prove the following.
We will also need the following lemma, which follows from [44, Lemmas 2 and 3], and has been initially made in the proof of [45,Proposition 7].
We can now state and prove the main result of this section.

Theorem 10. If U ∈ U d (C), appearing in the definition of F B , satisfies (H2), then any unitary matrix can be written as a product comprised of unitary matrices from
Proof.Let M ∈ N and D 1 , . . ., D 2M ∈ DU d (C) be such that (H2) holds.Then, using Proposition 8, the matrix has all non-zero entries.Note that this matrix is a product comprised of M matrices from F A and M matrices from F B .Next, using Lemma 9, we obtain that any unitary matrix can be written as a product of a number of matrices from Eq. ( 51) and a number of appropriately chosen diagonal unitary matrices.

Remark 11.
According to [44, Lemmas 2 and 3], we do not even need to demand in Lemma 9 that V contains a matrix with all non-zero entries.Instead we can only assume that V contains a matrix Q = (q ij ) d i,j=1 such that ∀ k,l∈{1,...,d} ∃ m∈{1,...,d} q km ̸ = 0 and q lm ̸ = 0. ( 52) This would, however, yield (due to [44, Lemmas 2 and 3]) that some matrix W with all non-zero entries also belongs to V.
To see that there exist both unitary matrices for which condition (H2) is satisfied and unitary matrices for which it is violated, let us refer to the theory of finite Markov chains (see Appendix G for a brief review of the subject).For a chosen finite Markov chain, let T denote its transition matrix.It is well known that in the case of T being irreducible and aperiodic [46], e.g., there exists a finite constant M such that for every m ≥ M the m-th step transition matrix T m consists only of non-zero elements (cf.Proposition 25 in Appendix G).Keeping this in mind, one can try to find a unitary matrix U ∈ U d (C) such that P T U P U (with P U induced by U via Eq.( 48)) has the same pattern of zero and non-zero elements as some irreducible and aperiodic transition matrix T , e.g., in the case of T given by Eq. (53) one can think of We then immediately get that U enjoys (H2) (for U given by Eq. (54), condition (H2) holds with M = 2).Another example, illustrating how to find in practice the number M appearing in (H2) (and not only claim that such a number exists and is finite), is provided in Appendix G. Proceeding now to "negative" examples, one shall take into account that both assumptions in Proposition 25 in Appendix G concerning finite Markov chains (i.e.irreducibility and aperiodicity of a transition matrix T ) are essential.Hence, we may conclude the following: 1. Any unitary matrix U such that P T U P U is reducible violates condition (H2).
2. Any unitary matrix U such that P T U P U is periodic violates condition (H2).Note, however, that for U ∈ U d (C) every diagonal element of P T U P U is positive, whence P T U P U cannot be periodic unless it is reducible -cf.Propositions 26 and 27 in Appendix G -and thus we end up in case 1.Now, it suffices to observe that all matrices U ∈ U d (C), which become block-diagonal after being multiplied by an appropriate permutation matrix (possibly also the identity matrix), violate condition (H2) (we conjecture that these are the only matrices violating condition (H2)).As precise examples we can either provide block-diagonal unitary matrices, such as or non-block-diagonal unitary matrices, such as which can be transformed to block-diagonal matrices by multiplying them by appropriate permutation matrices.

Bounds on the number of strokes to get all operations
We start with a statement on the lower bound on the number of resource engine's strokes needed to produce any unitary operation, the proof of which can be found in Appendix H. and [X U ] i,j = |u i,j | for all i, j ∈ {1, . . ., d}.
While the above lower bound is not tight (which can be seen by noting that for two mutually unbiased bases with c U = 1, the bound states N ≥ 2, and we know that already for d = 2 one needs 3 strokes), it nevertheless provides useful information when Alice's and Bob's bases do not differ much and so more strokes are required.This is illustrated in Fig. 4, where we plot this bound for a family of unitaries U defining F B continuously connecting the identity matrix with the Fourier matrix.
The upper bound on the number of strokes needed to produce any operation V ∈ U d (C) (with an arbitrary positive even number d) will be implicitly expressed by means of the number N F of strokes needed to generate the Fourier matrix.Proposition 13.Let d ≥ 4 be an arbitrary even number and suppose that the sets F A and F B are given by Eqs.(39a)-(39b) with an arbitrarily fixed matrix U ∈ U d (C).Moreover, let N F denote the number of resource engine's strokes needed to generate the Fourier matrix F d of order d.Then, the number N of resource engine's strokes needed to generate an arbitrary operation Proof.In Ref. [47], an analytical and deterministic procedure to design an implementation of an arbitrary unitary transformation is provided with the use of Fourier transforms and phase masks.According to the results established there, an arbitrary unitary of order d requires, in the case of d being an even number, 6d Fourier matrices and 6d+1 diagonal unitary matrices (implemented by phase masks).The assertion of this proposition is then a straightforward consequence of this fact.
In the end let us indicate that, according to Ref. [45], every U ∈ U d (C) (no matter whether d is even or odd) can be decomposed as a sequence of unitary circulant and unitary diagonal matrices.What is more, it can further be written as a product comprised of unitary diagonal matrices and the discrete Fourier transforms (since any circulant matrix can be written as a product of the Fourier matrix, some diagonal matrix, and the inverse of a Fourier matrix).However, to the best of our knowledge, there are no other results, apart from Ref. [47], to which we refer in the proof above, on the number of unitary diagonal matrices and Fourier matrices needed to generate a given unitary matrix.In Ref. [48], the authors prove that an arbitrary complex matrix can be written as a product of circulant and diagonal (but not necessarily unitary) matrices with the number of factors being 2d−1 at most.

Condition on getting the optimal state
In this section, we focus on the problem of using a coherence engine to generate a maximally mutually coherent state |ψ * ⟩ with respect to Alice's and Bob's distinguished bases.Such a state has the following form, and we discuss their existence for arbitrary d-dimensional systems in Appendix E. In particular, we ask for which matrices U (which determine the set F B ), the state |ψ * ⟩ can be generated in only three strokes (i.e., Alice prepares a state from F A , sends it to Bob who transforms it via one of the unitaries belonging to F B , and finally sends it back to Alice, who performs a unitary from F A ).A set of necessary conditions for this task is given by the following result.
The following conditions are necessary for a coherence engine to produce a maximally mutually coherent state with just three strokes: where l, m, i ∈ {1, . . .d}. Equivalently, Detailed proof of the above proposition can be found in Appendix E and here we briefly explain the idea behind it.First, one notes that the task of generating a maximally mutually coherent state |ψ * ⟩ (using just three strokes of a coherence engine) is possible if there exist l ∈ {1, . . ., d}  The generalised polygon inequalities then imply the assertion of Proposition 14.
The obvious consequence of Proposition 14 is the following corollary.
then one of the necessary conditions from Eq. (61) (namely the one with m = l) is violated, and thus Alice and Bob are not able to generate a maximally mutually coherent state with just three strokes of a coherence engine.
It is also interesting to observe that whenever a matrix U ∈ U d (C) is, in a certain sense, too close to the some permutation matrix, then at least one of the necessary conditions given in Eq. (61) is violated.This is more formally captured by the following.
) be a matrix defining F B via Eq.(39b).If for some permutation matrix Π ∈ U d (C) and some D ∈ DU d (C), we have where ∥ • ∥ HS denotes the Hilbert-Schmidt norm, then Alice and Bob are not be able to generate a maximally mutually coherent state with just two resource engine's strokes.
Proof.First of all, note that Now, it suffices to observe the following general fact: we have According to Corollary 15, we therefore obtain the assertion of this proposition.

Outlook
In this work we have introduced the notion of a resource engine and used it to analyse the possibility and complexity of generating quantum states and channels from two different sets of free states and operations.The main motivation behind introducing and investigating the resource engine was due to the fact that it provides a natural way of fusing two (or more) resource theories, in the spirit of recent works on multi-resource theories [49].
In a sense, it allows one to study how compatible various constraints on allowed transformations are.What we have done here is just to start this kind of research by introducing ideas and analysing simple toy examples, but we hope that a formal mathematical framework allowing for fusing arbitrary resource theories can be developed.Two potential ways to achieve this could be to extend to multiple resources the framework of general convex resource theories [50], or the very recent framework for quantifying resource-dependent complexity of quantum channels [51].
We also want to point out that the resource engine perspective may provide a unified framework to study seemingly unrelated problems within the field of quantum information.First, as explained in Sec.3.1, our toy example, given by a setting with two agents being constrained to performing unitaries diagonal in two different bases, can be directly related to the problem of compiling universal quantum circuits via Hamiltonian control [35][36][37].Thus, the results on resource engines could be applied to optimise quantum control and circuit compilation.Moreover, as discussed in the paper, a similar connection can be made with the problem of performing arbitrary optical linear transformations [47,52] (e.g., Alice can be restricted to performing only phase masks, while Bob can only perform Fourier transforms or beam splitters).
Another potential use of resource engines is in the area of quantum error correction.Here, transversal gates are crucial for fault-tolerant quantum computation because of their robustness to noise, as well as their simplicity.The problem is that no quantum error correcting code can transversely implement a universal gate set [53].However, by combining two error correcting codes with complementary transversal gate sets (so that together they are universal) via a method known as code switching [54,55], one can achieve fault-tolerance.Therefore, studies of resource engines with two restricted sets corresponding to two transversal gate sets, can allow for optimising fault-tolerant quantum computation based on code switching.
Finally, one can also find applications for resource engines in analysing the generation and distribution of entanglement in quantum networks [56][57][58].Such a network is represented by a graph with vertices corresponding to communicating parties and edges denoting connections between parties via quantum channels.Thus, generating a specific multipartite entangled state in a network can be decomposed into steps, where at each step two parties connected via a channel can process their part of the state.The simplest scenario of a linear network with three nodes (so A connected with B and B connected with C), can then be investigated using our resource engine with two constraints given by local operations on AB and local operations on BC.Extending the resource engine to more constraints (equivalent of a heat engine having access to baths at various temperatures) would allow onto deal with more complex quantum networks and could help in analysing optimal protocols for generating particular entangled states (e.g., minimising the number of communication rounds).

A Thermomajorisation
Consider a d-dimensional quantum system described by a Hamiltonian H with eigenvalues E 1 ≤ • • • ≤ E d .Denote a fixed inverse temperature of the environment by β.Then, the thermal Gibbs distribution of the system is given by γ In order to construct a thermomajorisation curve of a probability vector p (which describes the occupations of different energy levels in a given energy-incoherent state), one first needs to reorder the entries of p according to the so-called β-order.To do so, denote by π(p) the reordering of {1, . . ., d} that sorts p i /γ i in a non-increasing order, The β-ordered version of p is then given by p β with p β i = p πi(p) .Next, the thermomajorisation curve of p relative to γ is given by a piecewise linear concave curve on a plane that connects the points l (j) given by for j ∈ {0, . . ., d}, where l (0) := (0, 0).Finally, p is said to thermomajorise q (relative to γ), denoted p ≻ γ q, when the thermomajorisation curve of p is never below that of q.
B Missing details in the proof of Theorem 1 We first need to show that Eq. (20) holds, i.e., p ≻ γ q ⇒ p ≻ γ q and p ≻ Γ q ⇒ p ≻ Γ q. (78) Without loss of generality, we can just prove the first of the above keeping γ general.The way to prove it is to show that p ≻ γ p which, due to transitivity of thermomajorisation order, leads to p ≻ γ q.For d = 2 this is trivial, since p = p.For d ≥ 3, first consider two energy levels E i ≤ E j , and a state r with r i = 0 and r j > 0.Then, there exists a Gibbs-preserving operation that, on the two-dimensional subspace spanned by energy levels E i and E j , achieves an arbitrary occupation (a, r j − a) for a ∈ [0, r j ].It is explicitly given by a matrix where 1 \(ij) denotes the (d − 2) × (d − 2) identity matrix on the subspace of all energy levels except E i and E j .In other words, it is always possible to move probability down the energy ladder to unoccupied levels.Since the first (d − 2) levels of p are unoccupied, a sequence of such operations can move the occupations from pd−1 down to all the energy levels, leading to a final distribution p.
Next, we proceed to demonstrating that Eqs.(22a)-(22b) hold, i.e., that for d ≥ 3 we have We start with the second statement.It can be simply proved by observing that for d ≥ 3 we have (by definition) r1 = 0, and so using T from Eq. (79) with i = 1, j = d and a = r d , all the occupation of level d can be moved to level 1.Since probabilities must be non-negative, the achieved value of q d = 0 is minimal.To prove Eq. (80a), we need to resort to thermomajorisation curves.Since r has only two non-zero entries, its thermomajorisation curve is given by three points, the first one being (0, 0) and the third one being (1, 1).The middle point is given by (g d , r d ) if r d ≥ g d /(g d−1 + g d ) and by (g d−1 , 1 − r d ) otherwise.In the first case, for the thermomajorisation curve of q to lie below that of r, its y component must be no higher than r d at the x component g d .Given that the thermomajorisation curve is concave, this means that q d ≤ r d .In the second case, the y component of the thermomajorisation curve of r at x component g d is given by (1−r d )g d /g d−1 .Therefore, for the thermomajorisation curve of q to lie below that of r, the maximum value of q d must be upper bounded by (1 − r d )g d /g d−1 .Moreover, this upper bound can be achieved by simply choosing q with that value of q d and all others proportional to the entries of the Gibbs state, i.e.,

C Proof of Lemma 3
Proof.We start from proving the first half of the lemma (related to distributions p, p ′ and p ′′ ).Consider a state p obtained from p by thermalising the first (d − 1) levels of the system with respect to the cold bath, i.e., Clearly, p ≻ γ p, as thermalising a subset of states is a thermal operation.Since and the remaining entries pi are proportional to the entries of the thermal distribution γ, the thermomajorisation curve of p with respect to γ is defined by three points: (0, 0), (γ d , p d ) and (1, 1).Thus, for the x component γ 1 , its y component is given by This means that p can be transformed to p ′ with the above occupation of the ground state p ′ 1 and the remaining occupations p ′ i simply chosen to be proportional to the entries of the thermal distribution γ.Finally, since thermomajorisation is transitive, we have p ≻ γ p ′ .The next step is to start with p ′ and thermalise levels {2, . . ., d} with respect to the hot bath, resulting in and the remaining entries p′ i are proportional to entries of the thermal distribution Γ, the thermomajorisation curve of p′ with respect to Γ is defined by three points: (0, 0), (Γ 1 , p ′ 1 ) and (1, 1).Thus, for the x component Γ d , its y component is given by This means that p′ can be transformed to p ′′ with the above occupation of the highest state p ′′ d and the remaining occupations p ′′ i simply chosen to be proportional to the entries of the thermal distribution Γ.Since thermomajorisation is transitive, we have p ′ ≻ Γ p ′′ .Combining everything together and using again the transitivity property of thermomajorisation, we end up with Eq. ( 28) (its half concerning p, p ′ and p ′′ ) with p ′′ satisfying Eq. (29a).Finally, to show that p ′′ d ≥ p d and p ′′ d ≤ Γd , one simply needs to use the assumption that Γ d ≤ p d ≤ Γd .Now, let us switch to the second part of the lemma.Consider a state q obtained from q by thermalising the levels {2, . . ., d} of the system with respect to the hot bath, i.e., Clearly, q ≻ Γ q, as thermalising a subset of states is a thermal operation.Since and the remaining entries qi are proportional to the entries of the thermal distribution Γ, the thermomajorisation curve of q with respect to Γ is defined by three points: (0, 0), (Γ 1 , q 1 ) and (1, 1).Thus, for the x component Γ d , its y component is given by This means that q can be transformed to q ′ with the above occupation of the highest excited state q ′ d and the remaining occupations q ′ i simply chosen to be proportional to the entries of the thermal distribution Γ.Finally, since thermomajorisation is transitive, we have q ≻ Γ q ′ .The next step is to start with q ′ and thermalise levels {1, . . ., d − 1} with respect to the cold bath, resulting in and the remaining entries q′ i are proportional to entries of the thermal distribution γ, the thermomajorisation curve of q′ with respect to γ is defined by three points: (0, 0), (γ d , q ′ d ) and (1, 1).Thus, for the x component γ 1 , its y component is given by This means that q′ can be transformed to q ′′ with the above occupation of the ground state q ′′ 1 and the remaining occupations q ′′ i simply chosen to be proportional to the entries of the thermal distribution γ.Since thermomajorisation is transitive, we have q ′ ≻ γ q ′′ .Combining everything together and using again the transitivity property of thermomajorisation, we end up with Eq. ( 28) (its half concerning q, q ′ and q ′′ ) with q ′′ satisfying Eq. (29b).Finally, to show that q ′′ 1 ≥ q 1 and q ′′ 1 ≤ γ1 , one simply needs to use the assumption that γ 1 ≤ q 1 ≤ γ1 .

D Proof of Proposition 6
The proof is based on the following crucial lemma.
Lemma 17. Assume γ and Γ satisfy the requirements of Proposition 6 from Eq. (34), and the initial state p satisfies ∀k : with for k > 1.Moreover, ∀k : For the sake of clarity of the argument, we defer the proof of the above lemma to the end of this appendix.The lemma tells us that a sequential interaction of the initial state p with a hot and a cold bath can transform it to a final state r.Since the final state r satisfies Eq. (96), one can apply Lemma 17 iteratively, starting from p[1] = γ.Thus, given a vector p[n] satisfying Eq. (93), we can transform it to p[n + 1] also satisfying Eq. (93) and with for k > 1.Now, we have where we have used the assumption Γ 1 < Γ d + Γ d−1 from Eq. (34).We thus have and because the exponentiated prefactor on the right hand side is strictly smaller than 1 (again, due to the assumption from Eq. ( 34)), we get lim Obviously both p d [n] and p d−1 [n] are positive, and so they both independently tend to zero as n → ∞.Through Eq. (97), this then means that lim which proves Proposition 6.Note that because the convergence is exponential, the ground state is only achieved in the limit n → ∞.The last remaining thing to show is to prove Lemma 17.
Proof of Lemma 17.For p satisfying Eq. ( 93), it is straightforward to show that it also satisfies ∀k : Given the above, the thermomajorisation curve of p with respect to the hot bath Γ is given by the following elbow points: {(0, 0), (Γ 1 , p 1 ), . . ., (1 Since, by assumption from Eq. ( 34), we have the thermomajorisation curve of p at the x position (1 − Γ 1 ) takes the value Clearly then, a piecewise linear concave curve defined by the following elbow points, lies below the thermomajorisation curve of p.As can be verified by direct calculation, such a curve is a thermomajorisation curve of a state q from Eq. (95a), which satisfies ∀k : This proves the first part of the lemma.
To prove the second part, we start by noting that Eq. (108) implies ∀k : Given the above, the thermomajorisation curve of q with respect to the cold bath γ is given by the following elbow points: Since, by assumption from Eq. ( 34), we have the thermomajorisation curve of q at the x position γ 1 takes the value Clearly then, a piecewise linear concave curve defined by the following elbow points, lies below the thermomajorisation curve of q.As can be verified by direct calculation, such a curve is a thermomajorisation curve of a state r from Eq. (95b), which satisfies ∀k : This completes the proof.

E Maximally mutually coherent states Existence and generation in three strokes
Let us start by recalling a known result about the existence of maximally mutually coherent states exist for any two given bases and in any dimension (see Ref. [42], whose results imply the statement; cf. also Refs.[41] and [43]).[43]).
Remark 19.The assertion of Theorem 18 follows from the fact that a great torus T d−1 embedded in a complex projective space CP d−1 is non-displaceable with respect to transformations by a unitary matrix U ∈ U d (C) (cf.[59]), meaning that the image of torus resulting from the action of U must intersect the original torus, in at least 2 d−1 points (for a more detailed explanation see, e.g., Ref. [43]).
Next, consider the problem of generating a maximally mutually coherent state by performing only three operations (preparation of |l⟩ by Alice, transformation U † D 1 U by Bob, and transformation D 2 by Alice).From what has been said above, this task can be reduced to guaranteeing the existence of l ∈ {1, . . ., d} and D 1 , D 2 ∈ DU d (C) such that U † D 1 U has a flat l-th column, i.e., and Note that D 2 is only responsible for fitting the phases α j , j ∈ {1, . . ., d}.

Qubit case
Before we proceed to the proof of Proposition 14, which deals with a general problem of generating a maximally mutually coherent state using just three strokes of a coherence engine, let us first show how the problem is solved in the case of a qubit (simple heuristics have been already presented in Sec.3.2, however this analytical proof can be more easily generalised to higher dimensions).

Proof of Proposition 14
Using the intuition from the case of a qubit, let us now conduct the proof of Proposition 14.
Proof of Proposition 14.The necessary condition in the case of d = 2 (namely, π/8 ≤ φ ≤ 3π/8) follows just from the triangle inequalities.For an arbitrary d ∈ N\{1, 2} the reasoning is analogous (with the difference that in higher dimensions the necessary conditions are no longer the sufficient ones).As already mentioned at the beginning of this appendix, to solve the given task, it suffices to find a matrix U = (u i,j ) d i,j=1 ∈ U d (C) for which Eq. ( 117) is satisfied with some |l⟩, l ∈ {1, . . ., d}, and some Writing it differently, we obtain (for D = diag(e iξ1 , . . ., e iξ d )) which is kind of an equivalent of Eq. ( 123).The generalised polygon inequalities then imply the assertion of Proposition 14.

F Proof of Proposition 8
In Sec.3.3, for any U ∈ U d (C), we have defined a matrix P U , whose entries are zero whenever the corresponding entries of U are zero, otherwise they are equal to 1 (cf.Eq. ( 48)).Here, it is convenient to additionally introduce a matrix R U = (r ij ) d i,j=1 over the field R + , which corresponds to U in the following sense: The aim of this appendix is to prove that hypotheses (H1) and (H2) are equivalent.For this, we shall first establish a few auxiliary facts.
We now proceed to the harder direction, i.e., to proving that for any (k, l) ∈ {1, . . ., d} Let us define We shall construct a matrix D ∈ DU d (C) such that Note that (R U R V ) kl ̸ = 0 if and only if d m=1 r km s ml ̸ = 0. Since the matrices R U and R V satisfy Eq. ( 129), we further get that there exists at least one m 0 ∈ {1, . . ., d} such that u km0 v m0l ̸ = 0.
For any (k, l) ∈ I let us define a vector with w (kl) m = u km v ml for all m ∈ {1, . . ., d}.
Further, let us also introduce the subsets G N of W given by and the corresponding sets of indexes with d (1)  m = If (k, l) ∈ I 1 , then w (kl) ∈ G 1 , and Hence, for (k, l) ∈ I 1 , we have Note that w For any (k, l) ∈ I 1 there is at most one value φ 1 ∈ (0, 2π) which violates Eq. (143).Since I 1 is a finite set, we see that the set is also finite.We can therefore easily choose φ 1 ∈ (0, 2π) such that Eq. ( 142) holds for all (k, l) ∈ I 1 .In particular, it suffices to take any number φ 1 from the uncountable set F ′ 1 = (0, 2π)\F 1 .Now, let N ∈ {1, . . ., d − 1}, and suppose that the matrix D (N ) satisfies Moreover, assume that D (N ) has the following form: where φ 1 , . . ., φ N ∈ (0, 2π) are some constants.Then we can introduce matrices The aim now is to prove that the constant φ N +1 can be always chosen in such a way that Define the sets F (N +1),u with u ∈ {1, . . ., N + 1} as Let us prove that for any u ∈ {1, . . ., N +1} the set F (N +1),u is finite.Fix u ∈ {1, . . ., N +1} and (k, l) ∈ I u arbitrarily.We have which is equal to zero if and only if N +1 ̸ = 0, then Eq. ( 151) is equivalent to which holds for at most one φ N +1 ∈ (0, 2π).On the other hand, if w N +1 = 0, then it follows from Eq. ( 151) that This, however, contradicts our assumption from Eq. (145).Hence, we see that for any u ∈ {1, . . ., N + 1} and, since I u is finite for any u ∈ {1, . . ., N + 1}, then so is we can guarantee that condition from Eq. ( 148) is fulfilled.Finally, recalling that I = n m=1 I m , we can define where and any F m,u is defined as in Eq. (154 To finally prove the equivalence of hypotheses (H1) and (H2) it suffices to establish the following lemma.
Lemma 24.Let U ∈ U d (C).For any M ∈ N there exist matrices D 1 , . . ., D 2M ∈ DU d (C) such that for any k, l ∈ {1, . . ., d} Proof.First of all, note that the assertion of Lemma 24 for M = 1 immediately follows from Corollary 23.To establish it for all M ∈ N, we shall conduct an inductive proof.Suppose that the assertion of Lemma 24 holds for some M ∈ N, i.e., there exist matrices D 1 , . . ., D 2M ∈ DU d (C) such that for any k, l ∈ {1, . . ., d} Eq. (159) holds.We will prove that, upon this assumption, there exist matrices D 2M +1 , D 2M +2 ∈ DU d (C) such that for all k, l ∈ {1, . . ., d} we have According to Corollary 23 (applied for P U ), there exists D ∈ DU d (C) such that, for all k, l ∈ {1, . . ., d}, P T U P U kl = 0 if and only if 1U † DU kl = 0. Now, keeping in mind the inductive assumption and the above, set and note that the matrices R V = P T U P U M and R W = P T U P U satisfy Eq. ( 129) for V and W , respectively.Hence, using Lemma 22, we obtain that there exists D ∈ DU d (C) for which the equivalence

G Relations to Markov chains
For the convenience of the reader, we summarise here certain definitions and facts concerning finite Markov chains, to which we refer in Sec.3.3.In particular, we focus on irreducible and aperiodic Markov chains (for more details see, e.g., Refs.[46,60]).Consider a time-homogenous Markov chain X = (X n ) n∈N0 with a countable state space Σ (equipped with a countably generated σ-field B(Σ) on Σ), and let T = {T ij : i, j ∈ Σ} with T ij = P(X n+1 = j|X n = i) for n ∈ N 0 (164) be its transition matrix.The m-th step transition matrices T (m) = {T ij (m) : i, j ∈ Σ} are given by and they describe the probabilities of getting from one state to another (or the same) in exactly m steps.We say that a state i ∈ Σ is accessible from a state j ∈ Σ if and only if there exists some non-negative constant m such that T ij (m) > 0. If i and j are accessible from each other, we call them communicating.It shall be noted that the communication relation is an equivalence relation.A Markov chain X is called irreducible if and only if its state space constitutes one communication class.In the graph-representation of the chain, for communicating states i and j there are directed paths from i to j and from j to i.As a consequence, a finite Markov chain is irreducible if and only if its graph representation is a strongly connected graph (a directed graph is strongly connected if every vertex is reachable from every other vertex).The period d(i) of a state i ∈ Σ of a Markov chain X is given by d(i) = GCD{n ≥ 1 : T ii (n) > 0}.We call a state i aperiodic if d(i) = 1.A Markov chain is aperiodic if and only if all its states are aperiodic.
The following well-known facts (whose proofs can be found, e.g., in Ref. [60]; cf.Corollaries 3.3.3and 3.3.4therein) shall be useful for our purposes.Proposition 25.Let X be an irreducible and aperiodic Markov chain with finite state space and transition matrix T .Then, there exists a finite constant M such that for all m ≥ M T ij (m) > 0 for all states i, j ∈ Σ, (166) meaning that T (m) is a matrix with all non-zero entries, and so any two states are communicating.
Note that the assertion of Proposition 25 might not hold if we abandon the assumption that a Markov chain is aperiodic.Indeed, there exist irreducible Markov chains such that all matrices T (m) have zero entries (and kind of a block structure).An exemplary transition matrix of such a chain is Proposition 26.If a Markov chain is irreducible, and additionally its directed graph has a vertex with a loop (which is equivalent to requiring that the transition matrix T of this Markov chain has at least one nonzero diagonal element), then it is also aperiodic.
As a corollary of Propositions 25 and 26 we obtain the following: Proposition 27.If a Markov chain has a directed graph which is strongly connected and has at least one vertex with a loop, then it is both irreducible and aperiodic.
Using Proposition 27, we can construct a simple example illustrating how to directly approach the problem of estimating the value m ∈ N describing the number of steps needed to generate a matrix T (m) with all non-zero entries.
Example 28.Let U ∈ U d (C), and let W be its unistochastic matrix, that is, W = U • Ū , where • represents the entrywise product (also known as Hadamard or Schur product).Consider a finite Markov chain described by a transition matrix T = W T W and a directed graph D with vertices {v 1 , . . ., v d }.If we assume that D is strongly connected and one of its vertices, say v i0 , has a loop, then, according to Proposition 27, we obtain the following: where T (m) denotes here a m-th step transition matrix, defined in Eq. (165).Willing to find a constant M for which the above condition holds, we may proceed as follows: 1. Since the graph D is strongly connected, for any i, j ∈ {1, . . ., d}, there exist α i := min {α ∈ N : T ii0 (α) > 0} and β j := min {β ∈ N : T i0j (β) > 0} , (169) which are finite.
3. Define M := 2 max i∈{1,...,d} α i .Since the matrix T = W T W is symmetric, we have Imagine that U ∈ U d (C), appearing in the definition of F B , is close to a diagonal matrix (meaning that the modulus of non-diagonal elements of U are small ).Our intuition then tells us that Alice and Bob have to communicate many times before they manage to generate an arbitrary unitary matrix, and this is reflected in the following lemma.which, in turn, implies that Alice and Bob are not able to generate any permutation matrix within N = 2M steps (i.e., M Alice's strokes and M Bob's strokes).As a consequence, we may claim that, in order to generate an arbitrary unitary matrix of order d, both Alice and Bob need to perform at least M min operations, with M min given as the smallest natural number satisfying Since the minimal number of strokes is given by N = 2M min , this concludes the proof.

Figure 1 :
Figure 1: Two-level athermality engine.(a)The space of incoherent states of a two-level system is given by a one-dimensional simplex with extremal points (1, 0) and (0, 1), corresponding to the ground and excited states, respectively.Thermal states with respect to the cold and hot temperatures are indicated by γ and Γ, whereas fixed points of transformations Πγ Π Γ and Π Γ Πγ are denoted by γ and Γ. Crucially, γ ( Γ) is always closer to the ground (excited) state than γ (Γ) is.(b) For initial states lying in the simplex between the fixed points γ and Γ, the transformations (Πγ Π Γ ) m and (Π Γ Πγ ) m bring the initial state towards these fixed points "from the inside".(c).For initial states lying in the simplex outside the segment connecting the fixed points γ and Γ, the transformations (Πγ Π Γ ) m and (Π Γ Πγ ) m bring the initial state towards these fixed points "from the outside".
d with 2 d−1 extreme points {f b }, each characterised by a bit string b = [b 2 , . . ., b d ] of length (d − 1) via the following: on b d , we start by generating Γ or γ (by Proposition 4 we can do this, as both of these states belong to F AB ).As a result, the occupation of level d is given by f b d .Next, set k = 1 and treat the first (d − k) levels as an unnormalised (d − k)-level state.Depending on b d−k , again using Proposition 4 we generate versions of the states Γ or γ restricted to these (d − k) levels (and unnormalised).Repeating this for k ∈ {2, . . ., d − 2}, we obtain the state with the occupation of the level k given by f b k .Finally, the occupation of the ground state is given by f b 1 simply by the normalisation condition.

Figure 2 :
Figure 2: Three-and four-level athermality engines.The space of incoherent states of a d-level system is given by a (d−1)dimensional probability simplex [(a) d = 3 and (b) d = 4].The set FAB of states achievable by an athermality engine after N → ∞ strokes is presented in blue (region obtained numerically for large enough N , so that increasing it does not lead to visible changes), the region excluded from FAB by Corollary 2 is depicted in red, and the lower bound obtained in Proposition 5 is indicated in green.Parameters chosen: (a) α = 1/3, β = 1/5, E k = k; (b) α = 1, β = 1/4, E k = k.

Figure 3 :
Figure 3: Two-level coherence engine.Rotating alternately in the σz and the n • σ eigenbases (i.e., around the ẑ and n axes, respectively) can generate a single rotation around arbitrary axis, in particular around ŷ. (a) Illustration of the right hand side of Eq. (44).(b) Illustration of the left hand side of Eq. (44).

Proposition 12 .Figure 4 :
Figure 4: Lower bound.The lower bound from Proposition 12 for the number of coherence engine's strokes needed to generate every unitary transformation, when the unitary U defining FB is given by F α d , with F d denoting the d-dimensional Fourier matrix, and the three plots correspond to d = 3 (top red), d = 5 (middle green) and d = 10 (bottom blue).
by means of a coherence engine, leads to a new resource theory with free states F AB ⊇ F A ∪ F B and free operations F AB ⊇ F A ∪ F B .The main questions that we address here are as follows.First, in Sec.3.3, we ask when F AB = U d (C), i.e., under what conditions a coherence engine can generate any unitary operation.Next, in Sec.3.4, we address this question quantitatively by asking about the number of strokes needed to achieve any operation from U d (C).We then switch the attention from operations to states and investigate the task of reaching a given pure quantum state via a number of strokes of a resource engine.In particular, in Sec.3.5, we analyse how quickly one can reach a state that is maximally resourceful (here: mutually coherent) with respect to both Alice's and Bob's constraints.However, before we present all of the above, we start with the simplest qubit example in Sec.3.2 to illustrate problems at hand.
Corollary 23.Let U ∈ U d (C), and let R U be an arbitrary matrix over the field R + satisfying Eq. (129) (in particular, it can be P U , given by Eq. (48)).Then there exist matrices D 1 , D 2 ∈ DU d (C) such that for any k, l ∈ {1, . . ., d} R