Counting complexity Created 2026-09-28 Updated 2026-11-05
Counting complexity studies the computational resources needed to count solutions. For a polynomial time decidable binary relation and a polynomial , a standard counting function isThe complexity class consists of these functions, equivalently the numbers of accepting computations of Nondeterministic Turing machines running in polynomial time. The witness encoding matters: counting computation paths and counting distinct outputs can give different answers.
For the propositional formula , the satisfying Boolean valuations are , and , so the answer is three. The associated decision problem asks only whether that count is positive. For a zero-one matrix, the permanent of a matrix counts perfect matchings in a bipartite graph. Testing whether any such perfect matching exists admits a polynomial-time algorithm, while counting them is -complete under polynomial-time Turing reductions.[ref]
Deterministic algorithm 2026-11-05
A deterministic algorithm has one prescribed next step for each permitted input and current computational state. Thus the same input and initial state give the same execution trace and, if execution terminates, the same output. This is a statement about the abstract transition rules, not about identical elapsed time on different computers.
Binary search with a fixed midpoint rule is deterministic: every comparison determines which remaining interval is searched next. Quicksort with a fixed pivot-selection rule is also deterministic, even though different inputs can produce very different running times. Determinism therefore does not imply a constant or small time complexity.
A randomized algorithm additionally receives random choices. Fixing its entire random-choice sequence makes its subsequent execution deterministic, but averaging over those choices is essential to its randomized guarantees. A Nondeterministic Turing machine is a different mathematical model: its branches describe possible computation paths, rather than a probability distribution supplied by an implementation.
Nondeterministic space complexity class Created 2026-10-07 Updated 2026-10-14
Languages accepted by Nondeterministic Turing machines using work space on every computation path, with acceptance defined by existence of an accepting path. Bounded-space loops do not prevent the reachability interpretation in the finite configuration graph.
Writing as P and as co-P, the known relationships among the four complexity classes areThe equality supplies both inclusions between P and co-P, and it also gives co-P NP and co-P co-NP.
For the equality, a deterministic polynomial-time algorithm halts on every input; interchange its accepting and rejecting outcomes to decide the complement of a set in the same polynomial time. For P NP, a Nondeterministic Turing machine can simply make no choices and follow the deterministic computation. Finally, if , then , whence by the definition of co-NP.
Let , accepted by a fixed Nondeterministic Turing machine in at most steps on every computation branch, for a polynomial . Since the transition relation is finite, there is a fixed constant bounding the number of choices at any step. Every branch can be specified by a word over an alphabet of length over a -symbol choice alphabet, padding unused choices after halting.
A deterministic Turing machine enumerates all such choice sequences and simulates the corresponding branches for at most steps each. It accepts if some simulation accepts, and rejects after all have failed. Every possible accepting branch is included, and the time cutoff guarantees termination even on invalid choice sequences. A standard direct simulation has only polynomial overhead per branch, givingfor a suitable polynomial . This is a deterministic exponential time bound. ThereforeHere EXPTIME means the union of deterministic time bounds over fixed positive integers , allowing the usual constant factors and finitely many small inputs.
Use Turing machines with a two-way read-only input tape, bounded by endmarkers, and a fixed finite number of read-write work tapes over a fixed finite alphabet. Work-tape cells count towards space complexity; the read-only input does not. For input length , use to include the small-length cases.
, or L, is the class of formal languages decided by a deterministic such machine using at most work-tape cells for some fixed constant . It must halt on every input and accept exactly the members.
, or NL, is the class of formal languages accepted by a Nondeterministic Turing machine with the same work-space bound on every computation branch. An input is accepted if and only if at least one branch accepts. One may require all branches to halt: the configuration graph has only a polynomial number of vertices, so a logarithmic space counter can stop any branch that has taken more steps than that bound. If an accepting computation exists, one exists with no repeated Turing machine configuration, so this convention does not change the complexity class.
In standard space complexity notation,
Directed reachability is NL-complete under logspace many-one reductions. For membership, let be the number of vertices. Store a current vertex, initially , and a counter initially zero. Accept immediately if the current vertex is . Otherwise guess a next vertex, verify by scanning the input that the appropriate directed edge exists, move there and increment the counter. Reject a branch that has made steps without reaching .
Whenever a directed walk reaches , removing closed portions between repeated vertices produces a path in a graph with at most edges. Thus this bound preserves all yes-instances. The current and guessed vertices and the counter use bits, while adjacency checks only need repeated read-only input scans. All branches halt, so directed reachability belongs to NL.
For hardness, let and fix a Nondeterministic Turing machine accepting in work space. On input , construct its configuration graph . A vertex is a possible Turing machine configuration within the fixed work-space bound. Put a directed edge exactly when one legal transition of on changes into . Take the initial Turing machine configuration as source, and add a fresh target with an incoming edge from every accepting Turing machine configuration. ThenThere are only a polynomial number of Turing machine configurations, by the count used in part (c). More importantly, their encodings have length . A logspace transducer can enumerate candidate encodings and pairs of candidate encodings with bits of counters. For each pair, it checks the finite transition rule, the scanned input symbol and the local work-tape change using work space. It emits the corresponding adjacency matrix entry or edge-list record. Invalid candidate encodings may be discarded or represented by isolated vertices.
The configuration graph is thus output by a logspace transducer, rather than stored in its work tapes. This supplies the required logspace many-one reduction from every and proves NL-completeness.
Past exam of the mathematics course of the University of Cambridge 2013 iii Paper 59 2 a Solution Created 2026-10-03 Updated 2026-10-07
With a read-only input tape, deterministic space complexity class consists of languages decidable by deterministic Turing machines using work-tape cells. The nondeterministic space complexity class uses Nondeterministic Turing machines, with the bound holding on every computation path and acceptance meaning that some path accepts. Input storage is not charged. We use the standard finite-state, fixed-alphabet model.
The Savitch theorem isFirst suppose a work-space budget is available. A configuration graph for computations restricted to cells has configurations encoded in bits: work contents, control state and head positions, including bits for the input head. Its size is at most for a machine-dependent constant . Add accept and exit sinks if needed; the size bound merely changes . A reachable configuration has a simple path of length smaller than the number of configurations.
For encoded configurations , define to ask whether a path of length at most exists. At , test equality or one transition. For , enumerate every candidate middle configuration and testAny path of the given length can be split into two halves of length at most ; conversely concatenation gives a path of length at most . This proves the recursion. Taking suffices. Depth is , and each recursive frame stores only its endpoints, the current middle configuration and counters in bits. The two recursive calls are made sequentially and reuse their space. The total is , even though the time can be very large.
The printed hypothesis does not say that is computable. The space-bound discovery by exit reachability removes that issue. Begin with and use the preceding recursion to test both whether an accepting state is reachable within the budget and whether a reachable state has a transition leaving the budget. Accept in the first case. If acceptance is absent and an exit is reachable, double and repeat. If neither is reachable, reject: all computations remain within this finite configuration graph, and none accepts.
Every path of the original machine uses at most cells. Once reaches that bound there can be no reachable exit, so this procedure terminates. The final budget is by doubling, and all stages reuse the same storage. Hence its deterministic space is without requiring a machine that first computes . This proves the stated general form.
Stephen Cook Created 2026-10-24 Updated 2026-11-05
Stephen Cook is a computer scientist whose 1971 paper established a foundational connection between the class NP and Boolean satisfiability. The Cook-Levin theorem is expressed in modern terminology by saying that Boolean satisfiability is NP-complete.[ref]
The Complexity of Theorem-Proving Procedures by Stephen A. Cook. Section 1, Theorem 1 and construction in its proof
The proof encodes the possible steps of a polynomially bounded Nondeterministic Turing machine as a Boolean formula. A satisfying assignment describes an accepting computation, and the formula has polynomial size. This makes polynomial-time reduction a way to compare apparently different computational tasks: an efficient general solver for the encoded problem would solve every problem in NP. Cook's broader work also connects mathematical logic with proof complexity.[ref]
https://www.cs.toronto.edu/~sacook/. Research publications and Logical Foundations of Proof Complexity
Portrait of Stephen Cook
. orcmid, Flickr photograph, 15 June 2012. Creative Commons Attribution 2.0 Generic., via Wikimedia Commons. Source.