Papers
Topics
Authors
Recent
Search
2000 character limit reached

Argument-Swap Protocol

Updated 5 July 2026
  • Argument-swap protocol is a unifying schema that defines when two operands should be exchanged or retained, using domain-specific decision mechanisms and correctness criteria.
  • In software, static-analysis tools use both cover-based morpheme checks and statistical methods to detect accidental argument swaps with improved precision through combined heuristics.
  • In quantum and blockchain systems, controlled swap operations and cryptographic predicates enable reliable state exchange, ensuring operational fidelity and secure asset transfers.

In the cited literature, an argument-swap protocol is not a single standardized formalism but a recurring pattern in which two semantically distinct operands are preserved, exchanged, compared, or conditionally transferred under explicit correctness constraints. In software analysis, the relevant object is the accidental interchange of positional arguments at a call site. In quantum information and structured-light systems, it is the controlled exchange of registers or amplitudes by SWAP, c-SWAP, SWAP\sqrt{\mathrm{SWAP}}, or iSWAP\sqrt{i\text{SWAP}}-type interactions. In networking and blockchain systems, it is the rule-governed exchange of entanglement resources or escrowed assets across a graph. Taken together, these works suggest that an argument-swap protocol is best understood as a protocol schema for deciding when two positions should remain fixed, when they should be exchanged, and how that decision is certified by names, measurements, capacities, or cryptographic conditions (Scott et al., 2020, Szatkowski et al., 2020, Dai et al., 2021, Xue et al., 2022).

1. Core abstraction

A common formal pattern appears across otherwise unrelated domains. In the software-analysis setting, a call f(a1,…,an)f(a_1,\dots,a_n) is problematic when arguments at positions ii and jj correspond semantically better to parameters pjp_j and pip_i than to pip_i and pjp_j. In the standard quantum setting, a controlled-SWAP gate acts on basis states by

∣c,a,b⟩↦{∣0,a,b⟩,c=0,∣1,b,a⟩,c=1,|c,a,b\rangle \mapsto \begin{cases} |0,a,b\rangle, & c=0,\\ |1,b,a\rangle, & c=1, \end{cases}

while the SWAP test transforms state overlap into a measurable control probability,

p(0)=1+∣⟨ψ∣φ⟩∣22.p(0)=\frac{1+|\langle \psi|\varphi\rangle|^2}{2}.

These formulations differ in ontology, but each isolates two payloads, a control or evidence mechanism, and a correctness criterion for exchange versus non-exchange (Scott et al., 2020, Szatkowski et al., 2020).

This suggests a unifying abstraction with three recurrent elements. First, there are two candidate “arguments,” broadly construed as call-site values, quantum subsystems, queued resources, or escrowed assets. Second, there is a decision mechanism, such as morpheme-level coverage, corpus statistics, a Hadamard-controlled interference pattern, a scheduling rule, or a hashlock circuit. Third, there is an application-specific notion of acceptable outcome: semantic alignment in code, large state overlap or exact SWAP in physics, bounded backlog in networking, or safety and liveness predicates in blockchain protocols.

2. Static-analysis protocols for swapped call arguments

In software engineering, the argument-swap problem arises in languages with positional arguments when two parameters share the same or compatible types and the call accidentally uses a non-canonical order. The motivating examples include signatures such as int kill(pid_t pid, int sig); followed by a call like kill(SIGKILL, cpid);, where the program type-checks but the process ID and signal are semantically interchanged. “Out of Sight, Out of Place: Detecting and Assessing Swapped Arguments” implements a static-analysis checker, SwapD, that exploits natural-language information in code rather than relying only on types or control/data flow. It extracts identifier names from AST nodes, splits them into morphemes with Ronin, compares argument and parameter morphemes with a domain-adapted similarity relation a∼pa \sim p, and combines two independent detectors: a cover-based checker and a statistical checker (Scott et al., 2020).

The cover-based checker defines

C(A,P)=min⁡p∈Pmax⁡a∈A(a∼p),\mathit{C}(A,P)=\min_{p\in P}\max_{a\in A}(a\sim p),

where AiA_i and PiP_i are the morpheme sets of argument ii and parameter ii. A candidate swap between positions ii and jj is produced when

C(Ai,Pi)<0.5,C(Aj,Pj)<0.5,C(A_i,P_i)<0.5,\quad C(A_j,P_j)<0.5,

but

C(Ai,Pj)>0.75,C(Aj,Pi)>0.75.C(A_i,P_j)>0.75,\quad C(A_j,P_i)>0.75.

The statistical checker instead uses corpus counts w(f,m,i)w(f,m,i) over triples (f,i,m)(f,i,m) and the relative-frequency score

ψ(f,m,i,j)=w(f,m,i)w(f,m,j),\psi(f,m,i,j)=\frac{w(f,m,i)}{w(f,m,j)},

requiring, among other conditions, that min⁡(ψ(ai,j,i),ψ(aj,i,j))>γ\min(\psi(a_i,j,i),\psi(a_j,i,j))>\gamma with γ=5\gamma=5. Cover-based candidates are then statistically vetted and filtered by heuristics, including white-list words such as swap, exchange, rotate, and flip, a maximum swap distance ∣i−j∣≤2|i-j|\le 2, geometric-pattern suppression, type checks, nearby declaration checks, nearby correct-call checks, and repeated swap-frequency checks within a caller. On 6541 Fedora 29 SRPM C/C++ projects totaling approximately 417 million lines of code, the full configuration C{1234}C\{1234\} achieved precision $0.6667$ with yield $154$ true positives; C{34}C\{34\} achieved precision ∼0.891\sim 0.891 with yield $90$. Across configurations, 4141 unique warnings were generated, 859 were manually triaged, and 183 were classified as true positives. The paper reports that 42% of the true positives involved names with more than one morpheme, and that the cover-based and statistical detectors had only modest overlap, with 15 shared true positives, so their combination materially increased coverage (Scott et al., 2020).

3. Controlled-SWAP and SWAP-test protocols

In quantum information, the canonical argument-swap primitive is the controlled-SWAP or Fredkin gate, together with the SWAP test. The SWAP test prepares the control qubit in ∣0⟩|0\rangle, applies a Hadamard, performs a c-SWAP on ∣ψ⟩|\psi\rangle and ∣φ⟩|\varphi\rangle, applies a second Hadamard, and measures the control. The resulting outcome statistics satisfy p(0)=(1+∣⟨ψ∣φ⟩∣2)/2p(0)=(1+|\langle\psi|\varphi\rangle|^2)/2, so repeated trials estimate overlap without full state tomography. “Implementation of a simultaneous message passing protocol using optical vortices” realizes a classical optical analog of this construction with structured light, using Laguerre–Gauss modes, polarization as the control, positive OAM indices m>0m>0 for Alice, and negative indices m<0m<0 for Bob (Szatkowski et al., 2020).

The optical protocol maps one control polarization to an even number of reflections and hence no OAM helicity flip, while the orthogonal polarization undergoes an odd number of reflections and therefore m→−mm\to -m, which exchanges Alice’s and Bob’s channels. After the two Hadamard-equivalent half-wave plates and the polarization-sensitive Mach–Zehnder interferometer, the output powers obey

Px∝∑m∣Am+Bm∣2,Py∝∑m∣Am−Bm∣2,P_x \propto \sum_m |A_m+B_m|^2,\qquad P_y \propto \sum_m |A_m-B_m|^2,

with overlap parameter

γ=Py−PxPy+Px=−2∑mRe(AmBm∗)∑m(∣Am∣2+∣Bm∣2).\gamma=\frac{P_y-P_x}{P_y+P_x} = -\frac{2\sum_m \mathrm{Re}(A_mB_m^\ast)} {\sum_m (|A_m|^2+|B_m|^2)}.

For binary phase encoding Am,Bm∈{+1,−1}A_m,B_m\in\{+1,-1\}, this simplifies to

γ=2nN−1,\gamma = 2\frac{n}{N}-1,

where n/Nn/N is the fraction of equal bits. The implemented system used one OAM channel per sender and many bits via time-division multiplexing, operated a digital micromirror device with a maximum rate of $9.5$ kHz and an effective modulation rate of $7.5$ kHz, and achieved approximately 40 time bins per detector integration window, corresponding to 40-bit messages per sender per comparison. The study reports comparisons for overlap values from 0% to 100% in 10% steps, together with a two-reference normalization scheme that used 100% and 0% overlap reference blocks to correct for drift and interferometric imbalance. A recurrent misconception is that this optical simultaneous message-passing protocol inherits quantum security from the SWAP test; the paper explicitly distinguishes it as a classical, quantum-mimetic implementation whose privacy-preserving character is logical rather than guaranteed by no-cloning or measurement disturbance (Szatkowski et al., 2020).

4. Exchange gates, partial swaps, and bidirectional state transfer

A second major line of work treats argument-swap as a coherent exchange interaction rather than as a comparison test. In superconducting transmon architectures, “High-fidelity iSWAP\sqrt{i\text{SWAP}} gates using a fixed coupler driven by two microwave pulses” studies two fixed-frequency qubits Q1,Q2Q_1,Q_2 coupled through a fixed-frequency transmon coupler QcQ_c, with only the coupler driven. The induced two-qubit gate has the form

Uswap=[10000cos⁡θ−isin⁡θ00−isin⁡θcos⁡θ00001],U_{\text{swap}}= \begin{bmatrix} 1&0&0&0\\ 0&\cos\theta&-i\sin\theta&0\\ 0&-i\sin\theta&\cos\theta&0\\ 0&0&0&1 \end{bmatrix},

and θ=π/4\theta=\pi/4 gives exactly iSWAP\sqrt{i\text{SWAP}}. The protocol uses two microwave tones on the coupler, tuned near two-photon resonances involving the coupler’s second excited state, together with smoothed flat-top Gaussian pulses. For the ABA architecture the paper reports fidelity ≈94.60%\approx 94.60\% after single-qubit phase compensation and >99.92%>99.92\% for a iSWAP\sqrt{i\text{SWAP}}-like target including a conditional phase ϕ≈1.044\phi\approx 1.044 rad; for the ABC architecture it reports ≈99.63%\approx 99.63\% and >99.93%>99.93\%, respectively, with ϕ≈0.246\phi\approx 0.246 rad (Xu et al., 2024).

A more representation-theoretic version appears in “The Power of Power-of-SWAP: Postselected Quantum Computation with the Exchange Interaction,” which defines exchange gates

U(θ)=eiθEij=cos⁡θ 1+isin⁡θ SWAP,U(\theta)=e^{i\theta E_{ij}}=\cos\theta\,\mathbf{1}+i\sin\theta\,\mathrm{SWAP},

so that U(π/4)=SWAPU(\pi/4)=\sqrt{\mathrm{SWAP}} and U(π/2)=i SWAPU(\pi/2)=i\,\mathrm{SWAP}. The paper introduces XQP circuits, consisting of computational-basis SPAM and exchange interactions only, and proves

PostXQP(π/4)=PostXQP=PostBQP=PP.\mathrm{PostXQP}(\pi/4)=\mathrm{PostXQP}=\mathrm{PostBQP}=\mathrm{PP}.

It further shows that efficient multiplicative-error simulation of XQP would collapse the polynomial hierarchy to its third level, that random SWAP\sqrt{\mathrm{SWAP}}-only circuits form unitary tt-designs over SU(2)SU(2)-invariant unitaries with t≥n−2t\ge n-2, and that the entangling power of U(θ)U(\theta) is

ep0(U(θ))=1−cos⁡(4θ)12,e_{p_0}(U(\theta))=\frac{1-\cos(4\theta)}{12},

maximized at SWAP\sqrt{\mathrm{SWAP}} (Burkat et al., 30 Mar 2026).

A third variant dispenses with universal local control and uses scrambling. “Bidirectional teleportation using scrambling dynamics: a practical protocol” considers collective subsystems A,B,CA,B,C, global scramblers UABU_{AB} and UCB†U_{CB}^\dagger, and a postselection on subsystem BB. The effective map

S~AC=1p ⟨ϕ∣BUCB†UAB∣ϕ⟩B\tilde S_{AC}=\frac{1}{\sqrt{p}\,\langle\phi|_B U_{CB}^\dagger U_{AB}|\phi\rangle_B}

approximates SWAPAC\mathrm{SWAP}_{AC} when the mediator dimension satisfies dB≫dA2d_B\gg d_A^2, with average postselection probability pˉ≃1/dA2\bar p\simeq 1/d_A^2 in the optimal regime. The paper also proves a general dimension-dependent limitation: for dim⁡HA=dim⁡HC=d\dim \mathcal H_A=\dim \mathcal H_C=d and dim⁡HB=m\dim \mathcal H_B=m, there exists an input state with SWAP fidelity bounded by

F(Ψ)≤m+1d2+1.F(\Psi)\le \sqrt{\frac{m+1}{d^2+1}}.

The proposed implementation uses Dicke-type spin–boson dynamics in cavity-QED or trapped-ion systems, thereby making bidirectional state exchange an experimentally motivated protocol rather than only a circuit identity (Vikram et al., 21 Jan 2026).

5. Resource-swapping in quantum networks

In quantum networking, swapping is a scheduling and queueing operation rather than a gate applied to two qubits in isolation. “Entanglement Swapping in Quantum Switches: Protocol Design and Stability Analysis” studies a star topology with one quantum switch and KK end nodes. Link-level Bell pairs ∣Ψ0i⟩\ket{\Psi_{0i}} arrive at rates pip_i, entanglement requests Aij(t)A_{ij}(t) enter queues Uij(t)U_{ij}(t), and the switch chooses swap attempts Fij(t)F_{ij}(t), each succeeding with probability qq, subject to the resource constraints

∑iFij(t)≤E0j(t)+C0j(t),∑i,jFij(t)≤W.\sum_i F_{ij}(t)\le E_{0j}(t)+C_{0j}(t),\qquad \sum_{i,j}F_{ij}(t)\le W.

The capacity region is characterized by flow variables fijf_{ij} satisfying

∑ifij≤pj,∑i,jfij≤W,λij≤qfij.\sum_i f_{ij}\le p_j,\qquad \sum_{i,j}f_{ij}\le W,\qquad \lambda_{ij}\le q f_{ij}.

Stability is defined through

gij(V)=lim sup⁡t→∞1t∑τ=0t−1Pr⁡[Uij(τ)>V],g_{ij}(V)=\limsup_{t\to\infty}\frac1t\sum_{\tau=0}^{t-1}\Pr[U_{ij}(\tau)>V],

with stability requiring gij(V)→0g_{ij}(V)\to 0 as V→∞V\to\infty. The paper develops stationary protocols, on-demand protocols that need not know λij\lambda_{ij}, pkp_k, or qq, and an on-demand protocol with virtual requests

A~ij(t)=Aij(t)+⌈(t+1)α⌉−⌈tα⌉,α∈(1/2,1),\tilde A_{ij}(t)=A_{ij}(t)+\lceil (t+1)^\alpha\rceil-\lceil t^\alpha\rceil,\qquad \alpha\in(1/2,1),

which achieves zero average latency under stronger assumptions. In discrete-event simulations with K=4K=4 or K=8K=8, slot length $1000$ ns, p=0.9p=0.9, q=0.9q=0.9, memory slots per interface of 100, and T2=1T_2=1 ms, the on-demand protocols were reported as computationally efficient and as achieving high fidelity and low latency (Dai et al., 2021).

6. Predicate-based asset swaps and HTLC characterizations

In distributed-ledger systems, an argument-swap protocol becomes a cryptographically enforced exchange of assets across a directed graph. “Invited Paper: Fault-tolerant and Expressive Cross-Chain Swaps” models a swap as a strongly connected digraph G=(V,A)G=(V,A), with a Boolean variable for each arc and a predicate for each participant. The general safety predicate is

Sx:=(⋀i=1k((x,ui)  ⟹  Ix(x,ui)))∧Ox,S_x := \left( \bigwedge_{i=1}^k ((x,u_i)\implies I_x^{(x,u_i)}) \right)\wedge O_x,

and the liveness predicate is

Lx:=Sx∧(⋁i=1kIx(x,ui)).L_x:=S_x\wedge \left(\bigvee_{i=1}^k I_x^{(x,u_i)}\right).

Global solutions satisfy

ϕ(P)=⋀p∈Pp,\phi(\mathcal P)=\bigwedge_{p\in\mathcal P} p,

and each satisfying assignment defines a feasible swap digraph GsG_s. The paper introduces redundancy providers, conflicting solutions, and two protocols. ProtocolA is described as high collateral and fast settlement: it computes all satisfying solutions, builds swap schemes for them, runs escrow in parallel, and then selects a maximal non-conflicting subset ScS_c for redeem. ProtocolB is low collateral and fixed time: it augments each predicate with an exclusivity constraint rxr_x, imposes an ordering S∗={s1∗,…,sk∗}S^\ast=\{s_1^\ast,\dots,s_k^\ast\}, and uses priority-sensitive circuits

Csj∗,qnew:=(⋀i<jq′∈Q(T(S))sj∗ conflicts with si∗¬Csi∗,q′)∧Csj∗,q.C^{new}_{s_j^\ast,q}:= \left( \bigwedge_{\substack{i<j\\ q'\in Q(T(S))\\ s_j^\ast \text{ conflicts with } s_i^\ast}} \neg C_{s_i^\ast,q'} \right)\wedge C_{s_j^\ast,q}.

The point of both constructions is that acceptable subsets of swaps can still complete even when some parties deviate, rather than enforcing only an all-or-nothing outcome (Xue et al., 2022).

A more restrictive but sharper line of work asks when standard HTLCs suffice. “On HTLC-Based Protocols for Multi-Party Cross-Chain Swaps” shows that an atomic HTLC-based protocol exists if and only if the swap digraph is a reuniclus digraph. In the single-secret case, the exact class is the bottleneck digraphs. The paper defines bottleneck digraphs as strongly connected digraphs with a vertex lying on every cycle, gives the BDP protocol for that case using distances Dv−D^-_v, Dv+D^+_v, and timeouts

τuv=D∗+Dv+,\tau_{uv}=D^\ast + D^+_v,

and generalizes to reuniclus digraphs with RDP, using bottleneck components arranged in a rooted tree, the distance parameter Bv−B^-_v, and timeouts

τuv=B∗+Dv+.\tau_{uv}=B^\ast + D^+_v.

The main negative result is equally important: HTLC-only mechanisms are not sufficient for arbitrary strongly connected digraphs under the paper’s model, so atomic multi-party swap design has a sharp topological boundary (Clark et al., 2024).

7. Comparative perspective and limitations

A recurrent misconception is that any swap primitive is interchangeable with any other. The literature instead records domain-specific notions of evidence, correctness, and feasibility. In software, SwapD is heuristic and depends on meaningful identifier names, English-like morphemes, empirically chosen thresholds, and the assumption that most code in the corpus is correct; it is explicitly limited by naming quality, macro complexity, and the possibility that false-positive filters suppress real bugs (Scott et al., 2020). In structured-light simultaneous message passing, the measurement yields a global similarity metric without bitwise readout, but the implementation uses classical intense light and therefore does not inherit the physical privacy guarantees of quantum fingerprinting (Szatkowski et al., 2020).

Quantum gate constructions also separate naturally into different regimes. Exchange-only models such as XQP are sub-universal without postselection yet remain hard to simulate under standard complexity assumptions; this places them in an intermediate regime rather than identifying them with unrestricted BQP (Burkat et al., 30 Mar 2026). Scrambling-based SWAP protocols succeed only probabilistically and require a mediator dimension scaling as dB≫dA2d_B\gg d_A^2 for high-fidelity generic SWAP, so global interactions alone do not remove capacity constraints (Vikram et al., 21 Jan 2026). In blockchain settings, standard atomicity and fault tolerance are not the same property: all-or-nothing protocols can be safe while still failing to complete any acceptable subset after deviation, whereas predicate-based protocols address precisely that gap; conversely, when one restricts the execution layer to standard HTLCs, expressiveness is lost and only reuniclus digraphs admit atomic protocols (Xue et al., 2022, Clark et al., 2024).

Taken as a whole, the cited work supports a precise but plural understanding of argument-swap protocols. They are protocols whose central operation is an exchange decision between two positions, but the surrounding theory depends on the substrate: morpheme semantics in static analysis, interference and overlap in optical and quantum systems, flow constraints in network switches, and predicates plus cryptographic timing in distributed ledgers. The term therefore names a family of protocol designs rather than a single canonical construction.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Argument-Swap Protocol.