Exercise 5.16 (Scott 1981, PRG-19, Lecture V) — neg, merge and d on C #
Returning to Example 4.4 (the domain C of finite or infinite binary sequences),
this module gives
fixed-point/recursive definitions of three maps and verifies their characterizing
equations:
tail : C → C(tail(bx) = x,tail(Λ) = ⊥) — Scott's predecessor analogue, the item left to the reader in Example 4.4, built here with the head-test combinatorExercise419.liftC.neg : C → Cwithneg(0x) = 1·neg(x),neg(1x) = 0·neg(x)— bit-complement. We solve the recursion in closed form vialiftC(neg(σ) = (flip σ),flip = List.map not), prove the recursion equationsneg_cons_false/neg_cons_true(so it is the solution), and prove Scott's involution lawneg(neg x) = xfor allx ∈ |C|(negMap_negMap) — using that an approximable map is determined by its values on the finite elementsσ⊥,σ(Exercise 2.8,eq_of_toElementMap_principal), so it suffices to check the two-fold complement on those, where it isflip ∘ flip = id.d : C → C(d(Λ) = Λ,d(0x) = 00·d(x),d(1x) = 11·d(x)) — the bit-doubling map of Example 4.4, again vialiftC(d(σ) = double σ).merge : C × C → Cwithmerge(εx, δy) = ε·δ·merge(x, y)— bit-interleaving. Built directly as an approximable map out ofprod C Cfrom an explicit interleave value functionmergeVal. The boundary that Scott flags (merge(Λ, y)etc.) is resolved by the unique monotone convention (merge(Λ, y) = Λ,merge(εx, y) = ε⊥onceyruns out), the only choice compatible with approximability. We prove the recursion equation andmerge(x, x) = d(x)(mergeMap_diag).
All data (tail, negMap, dMap, mergeMap) is choice-free (#print axioms ⊆ {propext, Quot.sound}); equalities of maps go through eq_of_toElementMap_principal
(classical, exactly like
the project's ext_of_toElementMap).
The Thue–Morse properties of t = 0·merge(neg t, tail t) (its digit-sum-mod-2
description and
overlap-freeness) are real combinatorics-on-words and are left as a separate
follow-up.
Complement every bit of a finite string.
Equations
Instances For
flip is an involution.
flip preserves the prefix order.
double distributes over append.
double preserves the prefix order.
The approximation order on the finite elements σ⊥ and σ. #
A prefix relation descends to tails.
Two approximable maps out of C agree as soon as they agree on every finite
element σ⊥ and
σ (Exercise 2.8). This is the workhorse for the map equalities below.
tail : C → C — Scott's predecessor analogue (Example 4.4). #
The value of tail on a total element σ: tail(Λ) = ⊥, tail(bσ') = σ'.
Equations
Instances For
Exercise 5.16 / Example 4.4 — tail : C → C. Built with the head-test
combinator liftC:
on σ⊥ it returns (tail σ)⊥, on σ the total tail σ (with tail Λ = ⊥).
Equations
- One or more equations did not get rendered due to their size.
Instances For
tail(b(σ⊥)) = σ⊥.
tail(b(σ)) = σ.
neg : C → C — bit complement, neg(0x)=1·neg(x), neg(1x)=0·neg(x). #
Exercise 5.16 — neg : C → C. The closed-form solution of Scott's
recursion, built with
liftC: neg(σ⊥) = (flip σ)⊥ and neg(σ) = flip σ.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Exercise 5.16 — the recursion for neg, case 0. neg(0·x) = 1·neg(x)
as a map
identity.
Exercise 5.16 — the recursion for neg, case 1. neg(1·x) = 0·neg(x)
as a map
identity.
Exercise 5.16 (Scott 1981, PRG-19). neg ∘ neg = id as approximable maps:
it suffices to
check on the finite elements σ⊥, σ, where it is flip ∘ flip = id.
Exercise 5.16 (Scott 1981, PRG-19). neg(neg(x)) = x for all x ∈ |C|.
merge : C × C → C — bit interleaving. #
The principal elements of C are tagged strings (b, σ): b = true is the
total σ, b = false
the partial σ⊥. We encode the corresponding neighbourhood (shape) and
element (shapeElem),
the partial order between them (SLe), and the interleaving value function
mergeVal.
The neighbourhood of the tagged string (b, σ): {σ} if total, cone σ if
partial.
Equations
Instances For
The element of the tagged string (b, σ): total σ if b, partial σ⊥
otherwise.
Equations
Instances For
The approximation order between tagged strings: (b, σ) ⊑ (b', σ'). A total
string is maximal
(only ⊑ itself); a partial string σ⊥ is ⊑ anything extending σ.
Equations
Instances For
The interleave value function: mergeVal σ b₀ τ b₁ returns the interleaving
of the tagged
strings (b₀, σ) and (b₁, τ) as a tagged string. Boundary convention (the only
monotone one):
merge(Λ, y) = Λ, merge(⊥, y) = ⊥, and merge(εx, y) = ε⊥ once y runs out.
Equations
- Domain.Neighborhood.Exercise516.mergeVal [] x✝² x✝¹ x✝ = ([], x✝²)
- Domain.Neighborhood.Exercise516.mergeVal (a :: tail) x✝¹ [] x✝ = ([a], false)
- Domain.Neighborhood.Exercise516.mergeVal (a :: σ) x✝¹ (b :: τ) x✝ = (a :: b :: (Domain.Neighborhood.Exercise516.mergeVal σ x✝¹ τ x✝).1, (Domain.Neighborhood.Exercise516.mergeVal σ x✝¹ τ x✝).2)
Instances For
The element produced by interleaving (b₀, σ) and (b₁, τ).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The monotonicity of interleaving. If (b₀, σ) ⊑ (b₀', σ') and (b₁, τ) ⊑ (b₁', τ')
then the
interleavings are ⊑-ordered. The crux that makes merge approximable.
The element-order form of mergeVal_SLe.
The diagonal value: interleaving (s, σ) with itself doubles.
On the diagonal merge(⟨(s, σ), (s, σ)⟩) doubles σ.
A refinement lemma packaging both the representation and the order. #
The map merge. #
Exercise 5.16 (Scott 1981, PRG-19). The interleaving map merge : C × C → C with
merge(εx, δy) = ε·δ·merge(x, y). Built directly as an approximable map: an input
neighbourhood
shape b₀ σ ∪ shape b₁ τ relates to the neighbourhoods of mergeElem σ b₀ τ b₁.
Equations
- One or more equations did not get rendered due to their size.
Instances For
consMap b shifts a tagged string: b·(c, σ) = (c, b :: σ).
The value of merge on a pair of finite elements. merge(⟨(b₀, σ), (b₁, τ)⟩) = mergeElem σ b₀ τ b₁. The analogue of liftC_strBot/liftC_strElem for the
product.
Extensionality for maps C × C → C via finite element pairs. #
Two maps C × C → C agree as soon as they agree on every pair of finite
elements.
The recursion equation and merge(x, x) = d(x). #
Exercise 5.16 (Scott 1981, PRG-19). The defining recursion of merge:
merge(εx, δy) = ε·δ·merge(x, y) for all x, y ∈ |C| and bits ε, δ.
Exercise 5.16 (Scott 1981, PRG-19). merge(x, x) = d(x) for all x ∈ |C|
(the doubling map
of Example 4.4).