---
title: Slice-Subtraction Algorithm Overview
url: https://www.emergentmind.com/topics/slice-subtraction-algorithm
type: topic
---

# Slice-Subtraction Algorithm Overview

“Slice-Subtraction Algorithm” is not a standard algorithmic name in the arXiv literature. In the literature on subtraction games, the phrase most closely matches algorithms that process positions in ordered slices or intervals, especially the **PTFN algorithm**—short for **“\(P\)-position To Find \(N\)-position”**—for one-pile subtraction games [1208.3832], and a later divide-and-conquer interval method that propagates hot/cold information between contiguous heap-size slices by Boolean convolution [1804.06515]. In higher-dimensional vector subtraction games, the same interpretive label also fits segment-based methods that propagate \(\mathcal P\)-positions through semi-infinite slices by translation rules or a coloring automaton [2307.12458]. Outside combinatorial game theory, similar wording can also describe blockwise big-integer subtraction and sliding-window baseline subtraction, but those are distinct algorithmic traditions rather than a single unified method [1204.0220].

## 1. Terminology, formal setting, and scope

In its most developed mathematical use, a slice-subtraction algorithm operates on a **subtraction game**. For the standard one-pile normal-play case, the data consist of a finite subtraction set
\[
S=\{s_1,s_2,\dots,s_k\}, \qquad s_1<s_2<\cdots<s_k,
\]
a position given by a pile size \(n\), and legal moves \(n\mapsto n-s\) for \(s\in S\) with \(n\ge s\). The terminal position is \(0\), and the last player to move wins [1208.3832]. The standard recursive dichotomy is:
\[
0\in P,
\]
\[
n\in N \iff \exists s\in S,\ s\le n,\ \ n-s\in P,
\]
\[
n\in P \iff \forall s\in S,\ s\le n,\ \ n-s\in N.
\]

The later fast-evaluation literature uses equivalent hot/cold terminology. For a single heap,
\[
\operatorname{hot}(n)=\bigvee_{i\in S,\ i\le n}\neg \operatorname{hot}(n-i),
\]
with \(n=0\) cold in the ordinary subtraction game. For multi-heap subtraction games, the relevant invariant is the nim-value
\[
\operatorname{nimvalue}(n)=\operatorname*{mex}_{i\in S,\ i\le n}\operatorname{nimvalue}(n-i),
\]
and cold positions are exactly those with nim-value \(0\) [1804.06515].

In higher dimensions, a position becomes a vector
\[
\boldsymbol x=(x_1,\dots,x_d)\in \mathbb N_0^d,
\]
with finite subtraction set
\[
S\subseteq \mathbb N_0^d\setminus\{\boldsymbol 0\},
\]
and legal moves \(\boldsymbol x\mapsto \boldsymbol x-\boldsymbol s\) whenever \(\boldsymbol x-\boldsymbol s\ge \boldsymbol 0\) componentwise [2307.12458]. In that setting, “slice” usually refers not to a literal one-dimensional heap interval, but to rows, columns, wedge-shaped regions, or semi-infinite outcome segments.

A persistent source of confusion is that “Slice-Subtraction Algorithm” is an interpretive label rather than the title used by the cited papers. The principal named algorithms are **PTFN** in the 2012 one-pile paper [1208.3832], a divide-and-conquer **Boolean convolution** method for interval slices [1804.06515], and a **coloring automaton** for segmented higher-dimensional boards [2307.12458].

## 2. PTFN as a forward slice algorithm for one-pile subtraction games

The 2012 paper “A New Algorithm for the Subtraction Games” introduces the **PTFN algorithm**, whose defining idea is to start from known losing positions and mark all positions reachable from them in one move as winning positions [1208.3832]. Operationally, with an array \(X[0],X[1],\dots,X[n]\), the intended interpretation is:
- \(X[i]=0\): treated as a \(P\)-position unless later marked otherwise,
- \(X[i]=1\): an \(N\)-position.

The procedure is:
1. initialize \(X[0..n]\) to \(0\);
2. regard \(0\) as terminal and therefore a \(P\)-position;
3. scan \(i=0,1,\dots,n\);
4. whenever \(X[i]=0\), treat \(i\) as a \(P\)-position and, for each \(s\in S\) with \(i+s\le n\), set
   \[
   X[i+s]\leftarrow 1.
   \]

In cleaned form, the paper’s pseudocode is
```text
Input: pile size n, subtraction set S = {s1, s2, ..., sk}
Array X[0..n] initialized to 0

for i = 0 to n:
    if X[i] == 0:
        for each s in S:
            if i + s <= n:
                X[i + s] = 1
```
This is a **forward** procedure: known \(P\)-positions generate nearby \(N\)-positions, and anything left unmarked when reached becomes the next \(P\)-position. That is why the paper calls it **PTFN**: use \(P\)-positions to find \(N\)-positions [1208.3832].

The algorithm is naturally “slice-like” because it scans positions in increasing order and repeatedly applies the same local propagation rule on the integer line of heap sizes. The paper does not define formal slices, but the forward neighborhood of a newly discovered \(P\)-position \(i\),
\[
\{i+s:s\in S\},
\]
functions exactly as a local slice of newly classified \(N\)-positions.

The paper’s worked example uses
\[
S=\{1,3,7,8\}
\]
up to heap size \(21\). Under PTFN, the \(P\)-positions are
\[
0,2,4,6,15,17,19,21,
\]
and the remaining positions up to \(21\) are \(N\)-positions [1208.3832]. The paper’s comparison with Sprague–Grundy theory is also explicit: if \(G(x)=0\), then \(x\) is a \(P\)-position; if \(G(x)\neq 0\), then \(x\) is an \(N\)-position. PTFN avoids computing mex values and computes only the \(P/N\) classification.

This restriction is also its main limitation. The paper states that for sums of subtraction games, “Sprague-Grundy theory is better than PTFN algorithm, but for one pile subtraction games, PTFN has certain advantages” [1208.3832]. A plausible implication is that PTFN is best viewed as a direct outcome-classification method rather than a full replacement for nim-value computation.

## 3. Divide-and-conquer interval slicing and Boolean convolution

The 2018 paper “Faster Evaluation of Subtraction Games” develops a more literal slice-based algorithm: it recursively decomposes the heap-size range into contiguous intervals and propagates hot/winning information from one interval into the next using **Boolean convolution** [1804.06515]. In that setting, “slice” means an interval such as \([x,m)\) or \([m,y)\), and the computational gain comes from batching many predecessor checks.

The paper first introduces **subtraction games with hotspots**. Besides the subtraction set \(S\), one specifies a set \(H\) of heap sizes called hotspots; if a move leaves a heap in \(H\), the mover immediately loses. Then
\[
\operatorname{hot}(n)= n\in H \ \vee\ \bigvee_{i\in S,\ i\le n}\neg \operatorname{hot}(n-i).
\]
If some set \(C\) of positions is already known to be cold, then every position that can move to \(C\) is hot. That set is
\[
H = C + S = \{c+s \mid c\in C,\ s\in S\},
\]
which the paper writes as
\[
(i\in H)\Longleftrightarrow \bigvee_{j+k=i}(j\in C)\wedge (k\in S).
\]
Representing \(C\) and \(S\) as bitvectors turns this into a Boolean convolution, computable in
\[
O(n\log n)
\]
time by FFT-based numerical convolution followed by thresholding [1804.06515].

The divide-and-conquer algorithm for hot/cold status on an interval \([x,y)\) is:
1. recurse on the lower half \([x,m)\), where \(m=(x+y)/2\);
2. compute the set \(H_m\subseteq [m,y)\) of upper-half positions made hot by lower-half cold positions, using Boolean convolution;
3. recurse on the upper half \([m,y)\) with hotspot set enlarged by \(H_m\).

The runtime satisfies
\[
T(n)=2T(n/2)+O(n\log n),
\]
hence
\[
T(n)=O(n\log^2 n).
\]
The paper states this as:
> We can determine which positions are hot and which are cold, in a range of \(n\) positions of a subtraction game with hotspots, in time \(O(n\log^2 n)\) [1804.06515].

The same framework yields nim-values by repeated hotspot solves. If
\[
H_t=\{x:\operatorname{nimvalue}(x)\le t\},
\]
then the positions with nim-value \(t+1\) are exactly the cold positions of the hotspot game with hotspot set \(H_t\). If the maximum nim-value among \(0,\dots,n\) is \(m\), the total cost is
\[
O(mn\log^2 n),
\]
and the paper emphasizes that
\[
m\le |S|.
\]

This algorithm is significantly closer to a canonical “slice-subtraction algorithm” than PTFN, because it explicitly partitions the heap-size range into interval slices and uses a batched propagation step between them. The paper also discusses a simpler sieve-like cold-position algorithm:
1. initialize a Boolean array of hot marks to false;
2. for \(i=0\) to \(n\), if \(i\) is unmarked, output \(i\) as cold and mark \(i+s\) hot for every \(s\in S\).

That sieve runs in
\[
O(|C|\cdot |S|),
\]
where \(C\) is the set of cold positions up to \(n\), and for subtract-a-square it was faster than convolution in the tested range [1804.06515]. This shows that “slice-subtraction” in subtraction games spans both asymptotically fast interval methods and simpler forward sieves.

## 4. Segments, slices, and coloring automata in higher-dimensional subtraction games

The 2023 paper “Subtraction games in more than one dimension” generalizes the slice viewpoint from one-dimensional heap intervals to geometric regions in \(\mathbb N_0^2\) and higher [2307.12458]. For a two-move ruleset \(S=\{a,b\}\), the paper proves the \(\mathcal P\)-to-\(\mathcal P\) principle
\[
x\in\mathcal P \iff x+a+b\in\mathcal P.
\]
In vector form, for \(S=\{\boldsymbol s_1,\boldsymbol s_2\}\),
\[
\boldsymbol x\in\mathcal P \iff \boldsymbol x+\boldsymbol s_1+\boldsymbol s_2\in\mathcal P.
\]
This gives a complete reduction mechanism: repeatedly subtract \(\boldsymbol s_1+\boldsymbol s_2\) until reaching a smallest representative, then decide that representative locally.

In two dimensions, the paper makes the geometric structure explicit. For one-move games \(S=\{(a,b)\}\), the \(\mathcal P\)-positions are repeated \(L\)-shapes
\[
L_n= \{(x+2na,y)\mid 0\le x<a,\ 2nb\le y\} \cup \{(x,y+2nb)\mid 0\le y<b,\ 2na\le x\},
\]
and
\[
(x,y)\in\mathcal P \iff (x,y)\in \bigcup_{n\ge 0}L_n.
\]
For two-move rulesets \(S=\{(a,b),(c,d)\}\), the paper defines a slope
\[
\delta=\frac{b+d}{a+c}
\]
and partitions the board into regions \(A\), \(B\), \(C\), and mirrored counterparts; all further \(\mathcal P\)-positions are then generated by translations
\[
T(X)=\{(x+a+c,y+b+d)\mid (x,y)\in X\}.
\]

For three or more moves, a single translation vector is usually insufficient. The paper therefore introduces a **coloring automaton** on a segment
\[
\Gamma=\{(x,y)\mid \alpha x+k<y<\beta x+m\}\subset \mathbb N_0^2.
\]
A legal coloring scheme \((X_0,U,C)\) consists of an initial colored set \(X_0\subset \Gamma\), a finite color set \(C\), and a finite update set \(U\). Each update rule takes a colored position \((x,y,c)\) and outputs
\[
(x+u_1,y+u_2,c')\in \Gamma\times C.
\]
When the colored positions are exactly the \(\mathcal P\)-positions of the ruleset inside \(\Gamma\), the segment is an **outcome segment**.

This framework yields explicit segmented solutions for some three-move rulesets. The paper proves a perfect outcome segmentation into three segments for
\[
S=\{(1,2),(2,3),(3,1)\},
\]
and gives a segmentwise construction for symmetric additive rulesets
\[
S=\{(a,b),(b,a),(a+b,a+b)\}
\]
with update vectors
\[
r_1=(2a+b,2b+a),\qquad r_2=(2b+a,2a+b).
\]
The paper also proves that every finite two-dimensional subtraction ruleset has **row/column eventually periodic outcomes**, via a finite-window argument on
\[
W(x,y)=(o(x,y),o(x+1,y),\dots,o(x+A-1,y)),
\]
where \(A=\max_i a_i\) for \(S=\{(a_i,b_i)\}\) [2307.12458].

The paper’s computational visualizations go further and report a five-move ruleset with an outcome segmentation into **six semi-infinite slices**. That observation is empirical rather than a general theorem, but it places the term “slice-subtraction algorithm” on firm geometric ground: in higher dimensions, the slice is a region of the game board with a finite propagation law, not merely an interval of heap sizes.

## 5. Periodicity, empirical rules, and the PTFN-based period literature

The paper “The Period of the subtraction games” uses PTFN to study periodic behavior in finite subtraction games and argues that it is “more suitable than Sprague-Grundy Theory” for that task [1208.6134]. Its role in the history of slice-subtraction methods is methodological: PTFN is used to generate binary outcome sequences and to observe repeating blocks.

The paper presents four families of period formulas, including
\[
P = \begin{cases} k + 1& \text{if } k = 3n,\ n \in N^{+} \\ 3& \text{if } k \neq 3n,\ n \in N^{+} \end{cases}
\]
for \((1,2,k)\)-games, and
\[
P = 2s
\]
for a family of rulesets of the form
\[
(s,k_{1}(2s + 1),k_{2}(3s + 2),k_{3}(4s + 3),...,k_{n}((n + 1)s + n)),
\]
with \(k_i=0\) or \(1\) [1208.6134]. The practical procedure is to compute the \(0/1\) sequence of \(P/N\)-positions until a repeated block appears, then read off the period.

However, the paper also illustrates an important caution. Its theorem statements for \(\{1,3,k\}\) and \(\{1,k,k+1\}\) conflict with their own tables, and the text itself later describes Theorems 1–3 as “assumptions” [1208.6134]. This makes the article better read as a computational note on pattern discovery than as a complete proved theory. It remains relevant because it demonstrates a distinctive use of PTFN: not merely solving a bounded subtraction game, but using forward marking to expose eventually periodic structure.

A common misconception is that these period papers replace Sprague–Grundy theory. They do not. They replace full mex-valued computation by binary \(P/N\) propagation when the object of study is the period of the win/loss pattern rather than the full nim-sequence. That distinction is central to understanding both the strengths and the limits of slice-based subtraction-game algorithms.

## 6. Broader uses of the phrase and domain-specific ambiguity

Outside subtraction games, the expression can describe unrelated “slice” or “block” subtraction procedures. The paper “Sequential & Parallel Algorithms for Big-Integer Numbers Subtraction” proposes a blockwise decimal subtraction method in which large operands are partitioned into tokens of at most **18 decimal digits**, corresponding to about **60 bits**, and subtraction is performed tokenwise with borrow propagation [1204.0220]. In that setting, the slice is a fixed-size decimal token, the radix is
\[
\beta=10^{18},
\]
and the method has both sequential and parallel variants. This is a slice-based subtraction algorithm in arithmetic, but not in combinatorial game theory.

The paper “Informed baseline subtraction of proteomic mass spectrometry data aided by a novel sliding window algorithm” uses a different local-slice idea. Its baseline estimate is a morphological opening
\[
\omega_B(f)(x) := \delta_B(\epsilon_B(f))(x),
\]
and the baseline-subtracted signal is the top-hat
\[
\tau_B(f)(x) := f(x) - \omega_B(f)(x).
\]
Its novelty is a **continuous line segment algorithm (CLSA)** for rolling minima and maxima on an irregularly spaced transformed axis [1603.07082]. Here the slice is a sliding window
\[
[z_i-k/2,\; z_i+k/2],
\]
not a game-state interval or arithmetic token.

These uses matter because they show that “Slice-Subtraction Algorithm” is best understood as a **nonstandard umbrella label**. In subtraction games, it denotes forward or interval-based propagation schemes such as PTFN, Boolean-convolution interval decomposition, or segment-coloring automata [1208.3832]. In big-integer arithmetic, it denotes tokenwise borrow-resolving subtraction [1204.0220]. In signal processing, it denotes sliding-window baseline estimation [1603.07082]. A plausible implication is that the phrase has descriptive value, but only when its domain is specified.

Taken in the most coherent technical sense, the slice-subtraction algorithm is therefore a family of methods that exploit **ordered locality**—positions, intervals, tokens, or geometric segments—to replace naïve pointwise subtraction-state evaluation by structured propagation. In subtraction games, that family begins with forward \(P\)-to-\(N\) marking, becomes explicitly interval-recursive with Boolean convolution, and extends to geometric segmentation and coloring in higher dimensions [1804.06515].

Source: https://www.emergentmind.com/topics/slice-subtraction-algorithm