Documentation

CslibFrontier.DataStructure.VanEmdeBoas.WordRAM.Call

Complete native van Emde Boas calls and adaptive dynamic realization #

All three operations — insert (tag = 0), member (tag = 1), and strict successor (tag = 2) — execute on the same fixed 32-register dispatcher program, charging constant setup, dispatch branches, every loop instruction, and the final halt.

In addition, this module connects program to the shared DataStructure.StateTransitionSpec / DynamicProgram / DynamicCertificate interface on finite sets (Finset ℕ) and combines the uniform native initializer initProgram with arbitrary adaptive client histories (run_initialized). Native dynamic calls append a checked eight-instruction result conversion. Membership copies its answer into the shared flag register, and flags are normalized before canonical structural parsing. Their uniform halt-inclusive bound is 65 * (d + 1) + 30.

Main definitions #

Main results #

References #

The single compiled program contains 212 ordinary instructions and a final halt.

Compiling the fixed dispatcher introduces no word-width instruction.

The supported double-exponential universe has exactly d iterated binary logarithms.

Complete native insertion calls #

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.insert_dispatch_spec {d w base key : ℕ} {tree : Tree d} {s : WordRAM.Data 32} (ht : tree.Valid) (hr : Rep tree base s.mem) (hx : key < universeSize d) (ha : WordRAM.Fits w (base + span d)) (hroot : s.regs root = base) (harg : s.regs arg = key) (htag : s.regs tag = 0) :
∃ (z : WordRAM.Data 32), WordRAM.ExecWithin w program s z (39 * (d + 1) + 15) ∧ Rep (tree.insert key) base z.mem ∧ z.regs out = 0 ∧ ∀ (a : ℕ), a < base ∨ base + span d ≤ a → z.mem a = s.mem a

A complete insertion dispatch (tag = 0), including setup and all control flow but not final halt, executes in at most 39 * (d + 1) + 15 instructions, updates the represented tree to tree.insert key, leaves out = 0, and preserves all memory outside [base, base + span d).

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.insert_call {d w base key : ℕ} {tree : Tree d} {s : WordRAM.Data 32} (hs : WordRAM.Data.Bounded w s) (ht : tree.Valid) (hr : Rep tree base s.mem) (hx : key < universeSize d) (ha : WordRAM.Fits w (base + span d)) (hroot : s.regs root = base) (harg : s.regs arg = key) (htag : s.regs tag = 0) :
∃ (z : WordRAM.Data 32) (n : ℕ), n + 1 ≤ 39 * (d + 1) + 16 ∧ WordRAM.Exec w program s z n ∧ WordRAM.Data.Bounded w z ∧ Rep (tree.insert key) base z.mem ∧ z.regs root = base ∧ z.regs stackBase = s.regs stackBase ∧ z.regs out = 0 ∧ ∀ (a : ℕ), a < base ∨ base + span d ≤ a → z.mem a = s.mem a

A bounded caller invoking insertion (tag = 0) obtains a bounded state representing tree.insert key, with unchanged persistent root and stackBase registers and all memory outside [base, base + span d) preserved.

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.insert_executes {d w base key : ℕ} {tree : Tree d} {s : WordRAM.Data 32} (hs : WordRAM.Data.Bounded w s) (ht : tree.Valid) (hr : Rep tree base s.mem) (hx : key < universeSize d) (ha : WordRAM.Fits w (base + span d)) (hroot : s.regs root = base) (harg : s.regs arg = key) (htag : s.regs tag = 0) :
∃ n ≤ 39 * (d + 1) + 16, WordRAM.Executes w (program.program out) { pc := 0, data := s } 0 n

Actual flat bounded-word insertion execution, including its final halt, in 39 * (d + 1) + 16 instructions.

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.insert_executes_generic {d w base key : ℕ} {tree : Tree d} {s : WordRAM.Data 32} (hs : WordRAM.Data.Bounded w s) (ht : tree.Valid) (hr : Rep tree base s.mem) (hx : key < universeSize d) (ha : WordRAM.Fits w (base + span d)) (hroot : s.regs root = base) (harg : s.regs arg = key) (htag : s.regs tag = 0) :

Exact transfer of the flat insertion call into the shared generic RAM model.

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.insert_executes_log {d w base key : ℕ} {tree : Tree d} {s : WordRAM.Data 32} (hs : WordRAM.Data.Bounded w s) (ht : tree.Valid) (hr : Rep tree base s.mem) (hx : key < universeSize d) (ha : WordRAM.Fits w (base + span d)) (hroot : s.regs root = base) (harg : s.regs arg = key) (htag : s.regs tag = 0) :
∃ n ≤ 39 * (Nat.log 2 (Nat.log 2 (universeSize d)) + 1) + 16, WordRAM.Executes w (program.program out) { pc := 0, data := s } 0 n

The charged native insertion bound written directly in terms of the universe size.

Complete native membership calls #

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.member_dispatch_spec {d w base query : ℕ} {tree : Tree d} {s : WordRAM.Data 32} (ht : tree.Valid) (hr : Rep tree base s.mem) (ha : WordRAM.Fits w (base + span d)) (hroot : s.regs root = base) (harg : s.regs arg = query) (htag : s.regs tag = 1) :
∃ (z : WordRAM.Data 32), WordRAM.ExecWithin w program s z (28 * (d + 1) + 17) ∧ (z.regs out = if tree.member query = true then 1 else 0) ∧ z.mem = s.mem

A complete membership dispatch, including setup and all control flow but not final halt. No query-universe restriction and no zero-filled outside-memory assumption are imposed.

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.member_call {d w base query : ℕ} {tree : Tree d} {s : WordRAM.Data 32} (hs : WordRAM.Data.Bounded w s) (ht : tree.Valid) (hr : Rep tree base s.mem) (ha : WordRAM.Fits w (base + span d)) (hroot : s.regs root = base) (harg : s.regs arg = query) (htag : s.regs tag = 1) :
∃ (z : WordRAM.Data 32) (n : ℕ), n + 1 ≤ 28 * (d + 1) + 18 ∧ WordRAM.Exec w program s z n ∧ WordRAM.Data.Bounded w z ∧ Rep tree base z.mem ∧ z.regs root = base ∧ (z.regs out = if tree.member query = true then 1 else 0) ∧ z.mem = s.mem

A bounded caller obtains a bounded result, identical represented memory and an unchanged persistent root. Its query fits the machine word because every caller register does.

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.member_executes {d w base query : ℕ} {tree : Tree d} {s : WordRAM.Data 32} (hs : WordRAM.Data.Bounded w s) (ht : tree.Valid) (hr : Rep tree base s.mem) (ha : WordRAM.Fits w (base + span d)) (hroot : s.regs root = base) (harg : s.regs arg = query) (htag : s.regs tag = 1) :
∃ n ≤ 28 * (d + 1) + 18, WordRAM.Executes w (program.program out) { pc := 0, data := s } (if tree.member query = true then 1 else 0) n

Actual flat bounded-word execution, including its final halt, in 28 (d+1) + 18 instructions. The selected fixed program has no depth or word-width parameter.

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.member_executes_generic {d w base query : ℕ} {tree : Tree d} {s : WordRAM.Data 32} (hs : WordRAM.Data.Bounded w s) (ht : tree.Valid) (hr : Rep tree base s.mem) (ha : WordRAM.Fits w (base + span d)) (hroot : s.regs root = base) (harg : s.regs arg = query) (htag : s.regs tag = 1) :
∃ n ≤ 28 * (d + 1) + 18, GenericRAM.Executes w (program.program out).toGeneric (WordRAM.State.toGeneric WordRAM.Basis.standard { pc := 0, data := s }) (if tree.member query = true then 1 else 0) n

Exact transfer of the actual flat call into the shared generic RAM model; this adds no semantic operation or uncharged oracle instruction.

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.member_executes_log {d w base query : ℕ} {tree : Tree d} {s : WordRAM.Data 32} (hs : WordRAM.Data.Bounded w s) (ht : tree.Valid) (hr : Rep tree base s.mem) (ha : WordRAM.Fits w (base + span d)) (hroot : s.regs root = base) (harg : s.regs arg = query) (htag : s.regs tag = 1) :
∃ n ≤ 28 * (Nat.log 2 (Nat.log 2 (universeSize d)) + 1) + 18, WordRAM.Executes w (program.program out) { pc := 0, data := s } (if tree.member query = true then 1 else 0) n

The charged native membership bound written directly in terms of the universe size.

Complete native strict-successor calls #

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.successor_dispatch_spec {d w base stackBase₀ query : ℕ} {tree : Tree d} {s : WordRAM.Data 32} (ht : tree.Valid) (hr : Rep tree base s.mem) (hstk_lo : base + span d ≤ stackBase₀) (hstk_fit : WordRAM.Fits w (stackBase₀ + 4 * d)) (hroot : s.regs root = base) (hstk : s.regs stackBase = stackBase₀) (harg : s.regs arg = query) (htag : s.regs tag = 2) :
∃ (z : WordRAM.Data 32), WordRAM.ExecWithin w program s z (65 * (d + 1) + 21) ∧ (if z.regs found = 0 then none else some (z.regs out)) = tree.successor query ∧ Rep tree base z.mem ∧ z.regs sp = stackBase₀ ∧ ∀ (a : ℕ), a < stackBase₀ ∨ stackBase₀ + 4 * d ≤ a → z.mem a = s.mem a

A complete strict-successor dispatch (tag = 2), including setup, descent, and stack unwind but not final halt, executes in at most 65 * (d + 1) + 21 instructions, preserves the represented tree at base, restores sp = stackBase₀, and modifies no memory outside the 4 * d-word stack region [stackBase₀, stackBase₀ + 4 * d).

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.successor_call {d w base stackBase₀ query : ℕ} {tree : Tree d} {s : WordRAM.Data 32} (hs : WordRAM.Data.Bounded w s) (ht : tree.Valid) (hr : Rep tree base s.mem) (hstk_lo : base + span d ≤ stackBase₀) (hstk_fit : WordRAM.Fits w (stackBase₀ + 4 * d)) (hroot : s.regs root = base) (hstk : s.regs stackBase = stackBase₀) (harg : s.regs arg = query) (htag : s.regs tag = 2) :
∃ (z : WordRAM.Data 32) (n : ℕ), n + 1 ≤ 65 * (d + 1) + 22 ∧ WordRAM.Exec w program s z n ∧ WordRAM.Data.Bounded w z ∧ Rep tree base z.mem ∧ z.regs root = base ∧ z.regs stackBase = stackBase₀ ∧ z.regs sp = stackBase₀ ∧ (if z.regs found = 0 then none else some (z.regs out)) = tree.successor query ∧ ∀ (a : ℕ), a < stackBase₀ ∨ stackBase₀ + 4 * d ≤ a → z.mem a = s.mem a

A bounded caller invoking strict successor (tag = 2) obtains a bounded state with the exact optional successor encoded by (found, out), unchanged persistent root and stackBase registers, preserved tree representation, and unchanged memory outside [stackBase₀, stackBase₀ + 4 * d).

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.successor_executes {d w base stackBase₀ query : ℕ} {tree : Tree d} {s : WordRAM.Data 32} (hs : WordRAM.Data.Bounded w s) (ht : tree.Valid) (hr : Rep tree base s.mem) (hstk_lo : base + span d ≤ stackBase₀) (hstk_fit : WordRAM.Fits w (stackBase₀ + 4 * d)) (hroot : s.regs root = base) (hstk : s.regs stackBase = stackBase₀) (harg : s.regs arg = query) (htag : s.regs tag = 2) :
∃ (z : WordRAM.Data 32), ∃ n ≤ 65 * (d + 1) + 22, WordRAM.Executes w (program.program out) { pc := 0, data := s } (z.regs out) n ∧ (if z.regs found = 0 then none else some (z.regs out)) = tree.successor query ∧ Rep tree base z.mem ∧ ∀ (a : ℕ), a < stackBase₀ ∨ stackBase₀ + 4 * d ≤ a → z.mem a = s.mem a

Actual flat bounded-word strict-successor execution, including its final halt, in 65 * (d + 1) + 22 instructions.

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.successor_executes_generic {d w base stackBase₀ query : ℕ} {tree : Tree d} {s : WordRAM.Data 32} (hs : WordRAM.Data.Bounded w s) (ht : tree.Valid) (hr : Rep tree base s.mem) (hstk_lo : base + span d ≤ stackBase₀) (hstk_fit : WordRAM.Fits w (stackBase₀ + 4 * d)) (hroot : s.regs root = base) (hstk : s.regs stackBase = stackBase₀) (harg : s.regs arg = query) (htag : s.regs tag = 2) :
∃ (z : WordRAM.Data 32), ∃ n ≤ 65 * (d + 1) + 22, GenericRAM.Executes w (program.program out).toGeneric (WordRAM.State.toGeneric WordRAM.Basis.standard { pc := 0, data := s }) (z.regs out) n ∧ (if z.regs found = 0 then none else some (z.regs out)) = tree.successor query ∧ Rep tree base z.mem ∧ ∀ (a : ℕ), a < stackBase₀ ∨ stackBase₀ + 4 * d ≤ a → z.mem a = s.mem a

Exact transfer of the flat strict-successor call into the shared generic RAM model.

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.successor_executes_log {d w base stackBase₀ query : ℕ} {tree : Tree d} {s : WordRAM.Data 32} (hs : WordRAM.Data.Bounded w s) (ht : tree.Valid) (hr : Rep tree base s.mem) (hstk_lo : base + span d ≤ stackBase₀) (hstk_fit : WordRAM.Fits w (stackBase₀ + 4 * d)) (hroot : s.regs root = base) (hstk : s.regs stackBase = stackBase₀) (harg : s.regs arg = query) (htag : s.regs tag = 2) :
∃ (z : WordRAM.Data 32), ∃ n ≤ 65 * (Nat.log 2 (Nat.log 2 (universeSize d)) + 1) + 22, WordRAM.Executes w (program.program out) { pc := 0, data := s } (z.regs out) n ∧ (if z.regs found = 0 then none else some (z.regs out)) = tree.successor query ∧ Rep tree base z.mem ∧ ∀ (a : ℕ), a < stackBase₀ ∨ stackBase₀ + 4 * d ≤ a → z.mem a = s.mem a

The charged native strict-successor bound written directly in terms of the universe size.

Finite-set DataStructure.StateTransitionSpec and DynamicCertificate realization #

Tree.successor on a valid tree computes the mathematical OrderedSet.least of the stored elements strictly greater than the query.

Dynamic ordered-set operations supported by the van Emde Boas dispatcher.

  • insert (key : ℕ) : Operation

    Insert a bounded universe key into the set.

  • member (query : ℕ) : Operation

    Query whether a fitting word belongs to the set.

  • successor (query : ℕ) : Operation

    Return the least stored key strictly greater than a fitting query, if any.

Instances For
    @[reducible, inline]

    Typed observation returned by each van Emde Boas operation.

    @[reducible, inline]

    Abstract finite-set specification on the universe [0, universeSize d).

    Canonical native result formats: unit, exact Boolean, or tag followed by a natural word.

    The result format presents each operation's existing observation type by equality.

    A fixed bank shared by every operation: presence/Boolean flag, then successor payload.

    Native result conversion stages real constants, copies membership's answer to the shared flag register, and normalizes that register to exactly zero or one.

    The fixed dispatcher followed by its paid canonical result suffix, with a register-only calling convention (tag and arg) and one fixed output bank.

    structure Cslib.DataStructure.VanEmdeBoas.WordRAM.SetRep (d base stackBase₀ w : ℕ) (s : Finset ℕ) (x : WordRAM.Data 32) :

    Persistent machine representation of an abstract finite set s : Finset ℕ by a valid tree at base and scratch stack pointer at stackBase₀.

    theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.arguments_fit {d w base stackBase₀ : ℕ} (hstk_lo : base + span d ≤ stackBase₀) (hstk_fit : WordRAM.Fits w (stackBase₀ + 4 * d)) {s : Finset ℕ} (o : Operation) (ho : (spec d w).valid s o) (j : Fin 32) :

    Every encoded argument of a valid van Emde Boas operation fits the machine word width.

    theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.dispatch_spec {d w base stackBase₀ : ℕ} {s : Finset ℕ} {x : WordRAM.Data 32} (hstk_lo : base + span d ≤ stackBase₀) (hstk_fit : WordRAM.Fits w (stackBase₀ + 4 * d)) (o : Operation) (hx : SetRep d base stackBase₀ w s x) (ho : (spec d w).valid s o) :
    ∃ (y : WordRAM.Data 32), WordRAM.ExecWithin w ((dynamicProgram d w).code WordRAM.Basis.standard) ((dynamicProgram d w).prepare o x) y (65 * (d + 1) + 29) ∧ (dynamicProgram d w).decode o y.regs = some ((spec d w).stepFn s o).2 ∧ SetRep d base stackBase₀ w ((spec d w).stepFn s o).1 y ∧ ∀ (a : ℕ), a < base ∨ base + span d ≤ a → a < stackBase₀ ∨ stackBase₀ + 4 * d ≤ a → y.mem a = x.mem a

    Every admitted native call executes the original dispatcher and the paid canonical result suffix, retaining the represented set and all original memory framing guarantees.

    def Cslib.DataStructure.VanEmdeBoas.WordRAM.certificate {d w base stackBase₀ : ℕ} (hstk_lo : base + span d ≤ stackBase₀) (hstk_fit : WordRAM.Fits w (stackBase₀ + 4 * d)) :

    Semantic correctness and totality certificate for the fixed bounded-word van Emde Boas implementation.

    theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.instruction_bound {d w base stackBase₀ : ℕ} (hstk_lo : base + span d ≤ stackBase₀) (hstk_fit : WordRAM.Fits w (stackBase₀ + 4 * d)) :
    Bound (certificate hstk_lo hstk_fit).impl WordRAM.DynamicProgram.OperationTrace.instructions fun (x : (spec d w).State) (x_1 : (spec d w).Op) => 65 * (d + 1) + 30

    Separate worst-case per-operation instruction certificate, counting the final halt: every admissible insert, member, or successor call executes in at most 65 * (d + 1) + 30 instructions.

    theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.instruction_bound_log {d w base stackBase₀ : ℕ} (hstk_lo : base + span d ≤ stackBase₀) (hstk_fit : WordRAM.Fits w (stackBase₀ + 4 * d)) :
    Bound (certificate hstk_lo hstk_fit).impl WordRAM.DynamicProgram.OperationTrace.instructions fun (x : (spec d w).State) (x_1 : (spec d w).Op) => 65 * (Nat.log 2 (Nat.log 2 (universeSize d)) + 1) + 30

    The per-operation instruction certificate written in terms of the universe size.

    theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.execOp_frame {d w base stackBase₀ : ℕ} (hstk_lo : base + span d ≤ stackBase₀) (hstk_fit : WordRAM.Fits w (stackBase₀ + 4 * d)) {s : Finset ℕ} {o : Operation} {x y : WordRAM.Data 32} {a : (spec d w).Result o} {trace : WordRAM.DynamicProgram.OperationTrace} (hx : SetRep d base stackBase₀ w s x) (ho : (spec d w).valid s o) (he : (dynamicProgram d w).ExecOp w x o a y trace) {j : ℕ} (hj_tree : j < base ∨ base + span d ≤ j) (hj_stk : j < stackBase₀ ∨ stackBase₀ + 4 * d ≤ j) :
    y.mem j = x.mem j

    Every actual call preserves memory outside the tree region [base, base + span d) and the scratch stack [stackBase₀, stackBase₀ + 4 * d).

    theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.executes_client_frame {d w base stackBase₀ : ℕ} (hstk_lo : base + span d ≤ stackBase₀) (hstk_fit : WordRAM.Fits w (stackBase₀ + 4 * d)) {α : Type} {p : (spec d w).Client α} {s : Finset ℕ} {x y : WordRAM.Data 32} {val : α} {traces : List WordRAM.DynamicProgram.OperationTrace} (hx : SetRep d base stackBase₀ w s x) (hv : (spec d w).ValidHistory s ((spec d w).clientHistory s p)) (he : Executes ((dynamicProgram d w).ExecOp w) p x val y traces) {j : ℕ} (hj_tree : j < base ∨ base + span d ≤ j) (hj_stk : j < stackBase₀ ∨ stackBase₀ + 4 * d ≤ j) :
    y.mem j = x.mem j

    Every admissible adaptive client execution preserves memory outside the tree and stack regions across the entire interaction history.

    theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.client_spec {d w base stackBase₀ : ℕ} (hstk_lo : base + span d ≤ stackBase₀) (hstk_fit : WordRAM.Fits w (stackBase₀ + 4 * d)) {α : Type} (p : (spec d w).Client α) {s : Finset ℕ} {x : WordRAM.Data 32} (hx : SetRep d base stackBase₀ w s x) (hv : (spec d w).ValidHistory s ((spec d w).clientHistory s p)) :
    ∃ (y : WordRAM.Data 32) (traces : List WordRAM.DynamicProgram.OperationTrace), Executes ((dynamicProgram d w).ExecOp w) p x ((spec d w).clientResult s p) y traces ∧ SetRep d base stackBase₀ w ((spec d w).clientState s p) y ∧ total WordRAM.DynamicProgram.OperationTrace.instructions traces ≤ ((spec d w).clientHistory s p).length * (65 * (d + 1) + 30) ∧ ∀ (j : ℕ), j < base ∨ base + span d ≤ j → j < stackBase₀ ∨ stackBase₀ + 4 * d ≤ j → y.mem j = x.mem j

    Every admissible adaptive client has a concrete execution with the specified answers and final finite set, at most 65 * (d + 1) + 30 instructions per operation, and unchanged memory outside the tree and stack regions.

    theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.run_initialized {d w base : ℕ} {s₀ : WordRAM.Data 32} (hs₀ : WordRAM.Data.Bounded w s₀) (ha : WordRAM.Fits w (base + span d + 4 * (d + 1))) (hroot : s₀.regs root = base) (hdepth : s₀.regs depth = d) {α : Type} (p : (spec d w).Client α) (hv : (spec d w).ValidHistory ∅ ((spec d w).clientHistory ∅ p)) :
    ∃ (x₀ : WordRAM.Data 32) (n_init : ℕ) (y : WordRAM.Data 32) (traces : List WordRAM.DynamicProgram.OperationTrace), n_init + 1 ≤ 8 * span d + 20 * d + 25 ∧ WordRAM.Exec w initProgram s₀ x₀ n_init ∧ SetRep d base (base + span d) w ∅ x₀ ∧ Executes ((dynamicProgram d w).ExecOp w) p x₀ ((spec d w).clientResult ∅ p) y traces ∧ SetRep d base (base + span d) w ((spec d w).clientState ∅ p) y ∧ total WordRAM.DynamicProgram.OperationTrace.instructions traces ≤ ((spec d w).clientHistory ∅ p).length * (65 * (d + 1) + 30) ∧ ∀ (j : ℕ), j < base ∨ base + span d + 4 * (d + 1) ≤ j → y.mem j = s₀.mem j

    Combined native initialization and adaptive client execution: starting from any bounded machine state s₀ with s₀.regs root = base, s₀.regs depth = d, and Fits w (base + span d + 4 * (d + 1)) (with arbitrary initial memory), initProgram executes in at most 8 * span d + 20 * d + 25 instructions to produce an empty represented set x₀, from which any admissible adaptive client p executes to y with at most 65 * (d + 1) + 30 instructions per operation and no memory modified outside [base, base + span d + 4 * (d + 1)).