Past exam of the mathematics course of the University of Cambridge 2012 iii Paper 67 2 a Solution Created 2026-10-03 Updated 2026-10-07
Use the bit-query Boolean quantum oracle , where denotes workspace. Initially every probability amplitude is independent of , hence is a constant polynomial. An input-independent unitary gate only forms linear combinations of probability amplitudes, so it does not increase their polynomial degree.
If is an amplitude before a query, its new value isOne query increases polynomial degree by at most one. Inductively, after queries each amplitude has polynomial degree at most . The acceptance probability is a sum of squared absolute values of the accepting amplitudes, so it is a real polynomial of degree at most . Intermediate quantum measurements and classical adaptation can be retained coherently, or handled by summing unnormalized branch probabilities; either approach yields the same degree bound.
An exact algorithm has acceptance probability precisely at every Boolean input. The multilinear reduction on the Boolean cube replaces positive powers of each by , preserving these values without increasing polynomial degree. Therefore the polynomial method for quantum query lower bounds givesHere is the degree of the unique multilinear polynomial representing the Boolean function, and is its exact quantum query complexity. Uniqueness follows, for example, by evaluating successively on the indicator vectors of subsets: the value on a subset determines its coefficient once all smaller-subset coefficients are known.
Past exam of the mathematics course of the University of Cambridge 2012 iii Paper 67 2 e Solution Created 2026-10-03 Updated 2026-10-07
For a Boolean function , its block sensitivity at is the maximum number of pairwise disjoint nonempty index sets such that flipping all bits in each individually changes . Maximize over to obtain .
Choose , so every three-bit block has majority one and the conjunction is one. In each block, flipping either of its two one bits alone changes that block's majority to zero and therefore changes the conjunction to zero. These singleton index sets are all disjoint, soThe supplied bounded-error quantum query complexity lower bound now givesHere denotes a fixed two-sided error bound below , such as .
In fact the block sensitivity is exactly . At a one-input, selecting two one bits from each triple gives a size- certificate: any block flip changing the output must touch it, so disjoint sensitive sets number at most . At a zero-input, one failing triple contains at least two zero bits; fixing those two zeros certifies zero, so at most two disjoint sensitive sets can change the output. The lower-bound witness above attains . The certificate complexity of a Boolean function supplies these upper bounds, though only the witness is needed for the requested result.
Past exam of the mathematics course of the University of Cambridge 2026 iii Paper 168 1 ii Solution Created 2026-09-24 Updated 2026-09-25
It is enough to consider three alternatives . Encode each voter's three pairwise preferences by , where means , means , and means . A valid ranking excludes and . Independence of irrelevant alternatives gives three Boolean functions for the social comparisons. Unanimity and transitivity force : fixing arbitrary , taking and constantly equal to shows , and cyclic symmetry gives the claim.
Choose the voters' valid rankings independently and uniformly. A social Condorcet paradox is absent exactly whenThus transitivity for every profile gives . Conditional on , the bit equals with probability and differs with probability , so has correlation . ThereforeThe Fourier formula, valid for negative correlation, givesby Parseval identity. Among the numbers , the unique minimum is , attained at . Equality in this weighted average therefore forces all Fourier mass onto level one. Hence is a linear Boolean function with zero constant term. Such a function can have only one nonzero coefficient: otherwise varying two coordinates would make it assume more than two values. Thus or for some , making voter a dictator and proving Arrow theorem.
Past exam of the mathematics course of the University of Cambridge 2026 iii Paper 168 3 i Solution Created 2026-09-24 Updated 2026-09-25
The regularity lemma for Boolean functions states that for every there is such that every Boolean function has a set , , for which a -random satisfiesHere is the restriction obtained by fixing the coordinates in to .
A D flip-flop stores one bit. At its specified active clock edge, it samples and, after its clock-to-Q delay, makes equal to that sampled value. Between active clock edges it retains the stored value. The input must meet the setup and hold time requirements around the sampling edge; a level-sensitive latch would have different behavior.
For a finite-state sequential circuit, encode the present state in a bank of D flip-flops. Feed their outputs and the external inputs to combinational logic computing the next-state function , and connect those outputs to the flip-flop inputs. A common clock signal then performs the simultaneous updateOutput combinational logic computes for a Moore machine or for a Mealy machine. Since any finite next-state and output table is a Boolean function, it has a Boolean circuit implementation. Initialization specifies the starting state, and unused state encodings require either a recovery rule or an initialization assumption. The clock period must accommodate propagation through the D flip-flops and intervening combinational logic before the next sampling edge.
Write for a two-input NAND gate. Three elementary constructions areThe last identity is De Morgan's laws. To see that these operations suffice from first principles, take any finite truth table. For each row whose output is , form the conjunction of input literals that matches exactly that row: use when the row has , and when it has . Disjoin all such conjunctions. On any input, precisely its matching row conjunction can be true, so this disjunctive normal form equals the desired Boolean function.
Replace each negation, conjunction and disjunction by the displayed NAND gate constructions, nesting two-input gates for longer conjunctions or disjunctions. Constant outputs are available too: for any input , , and NANDing that value with itself gives . ThusA zero-input constant circuit additionally needs a supplied constant signal, such as a fixed logic supply. The positive-arity construction already covers constant-valued Boolean functions having one or more unused inputs.
For a three-input CMOS NAND gate, put three PMOS transistors in parallel from the positive supply to the output , and three NMOS transistors in series from to ground. Each input controls one device in each network:
A high input turns on its NMOS transistor and turns off its PMOS transistor; a low input does the opposite. If , every series NMOS transistor conducts and every PMOS transistor is off, pulling low. If any input is zero, its NMOS transistor breaks the series path and its PMOS transistor provides a path to , pulling high. ConsequentlyFor ideal settled inputs, the complementary networks do not simultaneously connect supply to ground. The CMOS arrangement gives a driven high or low output in every input case, rather than leaving the output floating.
A disjunctive normal form, also called a sum of products, is an OR of AND terms, each made from Boolean literals such as or . For example,Here juxtaposition means logical conjunction, means logical disjunction, and a bar means negation. The expression need not be canonical: a term can omit variables, and need not name a single row of the truth table.
Implement each product by an AND gate and combine the products with an OR gate. Supply complemented inputs with NOT gates. ThusThis is the usual two-level combinational logic realization, counting complemented inputs as available. If NOT gates are counted, a complemented input can traverse three gates. The two-level depth statement also assumes sufficiently large gate fan-in: using only two-input logic gates requires trees for long products or sums. Constant, single-product and single-literal Boolean functions may need fewer levels, so the two-level construction is a general bound, not a claim that every expression requires exactly two layers.
The unconstrained cases can be treated as don't-care conditions during Boolean function minimization. One particularly small, deliberately asymmetric choice isUse the same two history D flip-flops and one output D flip-flop, with this expression at the output D input. It requires two two-input AND gates and one OR gate.
To verify every required case, first set . If zero occurs at least twice among , then , so as required. If all three samples are one, then , so . The remaining triples have exactly two ones and hence exactly one sample agreeing with the old zero; either output is allowed.
Now set . If at least two samples are one, either or , giving . If all three samples are zero, both terms vanish, giving . The remaining triples have exactly one one and are the allowed don't-care conditions. Thus the expression meets both requirements, including every constant-input triple.
For minimality, consider these required one-entries in order: , , and have no common literal. Therefore a product covering all four would be the constant one, which violates required zero-entries. Also no single-literal product is safe: each of is one at some required zero-entry, and each complemented literal is one at . Hence at least two products with at least two Boolean literals each are needed. The displayed expression attains two products and four literals.
Use three positive-edge-triggered D flip-flops, all driven by the same clock signal . Write the current binary representation as , with the least significant bit. The next state is the current value plus one when and minus one when , in each case modulo eight. A bit toggles under exclusive or with a one.
For upward counting, toggles when , while toggles when , the respective carry conditions. For downward counting the corresponding borrow conditions are and . Define the shared inverted direction and the two direction-match signalsEach is one exactly when : it equals for upward counting and for downward counting. Thus the Boolean functions for the three D inputs areImplement this with two NOT gates for , four two-input exclusive or gates for , and one two-input AND gate. Connect to the D flip-flop whose output is ; feed the three outputs back into the indicated gates. All three flip-flops capture simultaneously, so each equation uses the old state.
For completeness, the state transition table is
| Current | Next for | Next for |
|---|---|---|
000 | 001 | 111 |
001 | 010 | 000 |
010 | 011 | 001 |
011 | 100 | 010 |
100 | 101 | 011 |
101 | 110 | 100 |
110 | 111 | 101 |
111 | 000 | 110 |
Every three-bit state is valid. A reset may initialize the binary counter to zero if required; counting itself needs no extra state. The direction input must meet the setup time and hold time requirements at the active clock edge.
Each parenthesized pair in the given Boolean function tests equality of two input bits:This is logical equivalence, or the two-input XNOR gate function. Thus is one whenever either input pair agrees. Generate the four complemented inputs with four inverters, and define the following NAND gate outputs:Feed these four outputs into a single four-input NAND gate. De Morgan's laws giveHere juxtaposition denotes logical conjunction. The construction uses only inverters, two-input NAND gates and one four-input NAND gate, as required.
Use a synchronous binary counter with three positive-edge-triggered D flip-flops, all driven by the same clock signal. Write their outputs , with the least significant bit. The next-state Boolean functions areImplement these with one NOT gate, two exclusive or gates, and one AND gate. Connect each to its corresponding D flip-flop; its output is address line . A reset input clears all three flip-flops to zero, so the first selected sensor is sensor zero.
The state sequence isThe low bit toggles at every clock edge, the middle bit toggles exactly when the old low bit is one, and the high bit toggles exactly when both old lower bits are one. These are precisely the carry conditions for incrementing a three-bit binary representation. Every possible state belongs to the cycle, so there is no unused state requiring recovery. Choose a clock period allowing the combinational logic to settle before the next capture.
Encode by , , , , with reset to . Two positive-edge-triggered D flip-flops store the state. Minimizing the Boolean functions from the complete table givesEquivalently, the minimal sum of products form of is . The displayed factorization saves duplicated logic. The equations use only AND gates, OR gates and NOT gates; connect to the corresponding flip-flop data input and use one common clock.
The two writable inputs and Boolean query belong to an abstract class; each concrete logic gate overrides just that query:All three subclasses satisfy the same object interface, so the
abstract class Gate {
var inp1: Boolean = false
var inp2: Boolean = false
def evalGate: Boolean
}
class OrG extends Gate {
override def evalGate: Boolean = inp1 || inp2
}
class AndG extends Gate {
override def evalGate: Boolean = inp1 && inp2
}
class XorG extends Gate {
override def evalGate: Boolean = inp1 ^ inp2
}Gate declarations in the supplied simulator still allow access to inputs and invoke the correct Boolean function through dynamic dispatch. Boolean ^ is exclusive or; || is Boolean disjunction and && is Boolean conjunction.The program first sets both inputs of Those are the two output lines. This is a simulation of combinational logic in an order where each gate's inputs have already been calculated; the Boolean assignments copy values rather than create live wire connections.
y, so . It sets . Therefore and , givingx: true
w: falseThe internal Boolean functions are , , , and . Put the falling edge of at . Since throughout, throughout. The remaining transitions, including every stated propagation delay, areThe inverter delays the rise of by ten nanoseconds, and the AND gate adds another ten. Consequently and are simultaneously zero for ten nanoseconds. This gap propagates through the two OR gates. The output has a static-one logic hazard: a low glitch on ns, despite its equal initial and final logical values.
Delayed transitions produce a ten-nanosecond static-one logic hazard
. The shaded interval marks the incorrect output pulse. Exact ten-nanosecond gate delays are used, including propagation of the pulse. Details.The lower network pulls the output low exactly when either series branch conducts. Therefore the Boolean function isThe inversion is important: describes connection to the low rail, not a high output. The pull-up network found in part a implements the complementary high condition.
Every AND gate and OR gate is a monotone Boolean function: changing an input from zero to one while leaving all other inputs unchanged cannot change the output from one to zero. By structural induction over a Boolean circuit, a composition of these gates is also a monotone Boolean function. Constant inputs do not alter that conclusion.
Logical negation cannot be implemented, since it sends to and to , violating the defining order property. Hence these two gate types alone cannot implement every Boolean function.
The pull-down Boolean function is . A conducting pull-down makes , soIn particular, if the output is always high; if , the output is high precisely when both other inputs are low. These cases give the truth table without confusing a network's conducting condition with the output voltage.
Factor the common input before constructing the networks. Use an NMOS transistor controlled by in series with parallel NMOS transistors controlled by and . Its conducting condition remains . The complementary upper network is a PMOS transistor controlled by in parallel with a series chain of PMOS transistors controlled by and ; its conducting condition is .
This is the right panel in part (a). It uses three lower plus three upper transistors, six in total instead of eight, and needs no separate inverter or complemented external input. The complementary CMOS network duality ensures the same static Boolean function and complementary rail connections.
Simultaneous propositional substitution givesLet . The first disjunct equals . By De Morgan's laws, implies , so absorption reduces that first disjunct to . The second disjunct is and is also absorbed by . ThereforeThe resulting Boolean function is false only when both and are true, providing a four-row truth table check.
The maximally variant safe declarations are:
trait Rel1[+X, +Y] { val pairs: List[(X, Y)] }
trait Rel2[-X, +Y] { def relatives(x: X): List[Y] }
trait Rel3[-X, -Y] { def related(x: X, y: Y): Boolean }Leaving one or both parameters invariant is also legal but admits fewer subtyping conversions. These are type variance annotations.
For
Rel1, both parameters occur only as outputs. Scala's immutable List and Tuple2 are covariant, so a list of pairs of narrower types can safely be read as pairs of broader types. Thus both may be covariant type parameters. A contravariant declaration would permit, for example, treating a Rel1[Any, Int] containing (7, 0) as a Rel1[String, Int], then reading its first component as a String. That would be unsound; the compiler rejects the negative annotation at this output position.For
Rel2, X occurs as a method argument and therefore may be a contravariant type parameter; Y is returned in an immutable list and may be a covariant type parameter. A function that accepts every Any is safe to use where only String queries are issued. The opposite direction would be unsafe: if X were covariant, the following hypothetical conversion could call a string-only implementation with an integer:val strings: Rel2[String, Int] = new Rel2[String, Int] {
def relatives(x: String): List[Int] = List(x.length)
}
// Unsafe if Rel2 were incorrectly covariant in X:
// val arbitrary: Rel2[Any, Int] = strings
// arbitrary.relatives(7)Making
Y contravariant would instead allow an integer-valued Rel2[String, Any] to be read as a string-valued Rel2[String, String], recreating the output error.For
Rel3, both generic values are consumed and only a Boolean function result is produced, so both may be contravariant type parameters. A predicate accepting all values of broad types can answer queries restricted to narrower types. Covariance in either parameter would allow passing an unsupported value to a specialized implementation. For example, treating a string-only first-argument predicate as accepting Any would permit related(7, y) even though its body might call x.length. These are applications of the variance-position rule: method inputs reverse variance, whereas immutable outputs preserve it.[ref]Scala 2.13 variance annotations specification. Variance annotations and the change of position in method parameter types


