Documentation

LeanPool.DomainTheory.Neighborhood.Exercise516

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:

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.

List helpers: bit-complement flip and bit-doubling double. #

@[reducible, inline]

Complement every bit of a finite string.

Equations
Instances For

    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.

    Determination by finite elements: an equality criterion for maps C → V. #

    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). #

    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

      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 flipflip = id.

        Exercise 5.16 (Scott 1981, PRG-19). neg(neg(x)) = x for all x ∈ |C|.

        d : C → C — bit-doubling, d(Λ)=Λ, d(0x)=00·d(x), d(1x)=11·d(x). #

        Exercise 5.16 / Example 4.4 — d : C → C. The doubling map, closed form via liftC: d(σ⊥) = (double σ)⊥, d(σ) = double σ.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          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
              theorem Domain.Neighborhood.Exercise516.shape_injective {b b' : Bool} {σ σ' : ExampleB.Str} :
              shape b σ = shape b' σ'b = b' σ = σ'

              The approximation order between tagged strings: (b, σ) ⊑ (b', σ'). A total string is maximal (only itself); a partial string σ⊥ is anything extending σ.

              Equations
              Instances For

                SLe characterizes the element order on shapeElem.

                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
                Instances For
                  @[simp]
                  theorem Domain.Neighborhood.Exercise516.mergeVal_nil (b₀ : Bool) (τ : ExampleB.Str) (b₁ : Bool) :
                  mergeVal [] b₀ τ b₁ = ([], b₀)
                  @[simp]
                  theorem Domain.Neighborhood.Exercise516.mergeVal_cons_nil (a : Bool) (σ : ExampleB.Str) (b₀ b₁ : Bool) :
                  mergeVal (a :: σ) b₀ [] b₁ = ([a], false)
                  @[simp]
                  theorem Domain.Neighborhood.Exercise516.mergeVal_cons_cons (a : Bool) (σ : ExampleB.Str) (b₀ b : Bool) (τ : ExampleB.Str) (b₁ : Bool) :
                  mergeVal (a :: σ) b₀ (b :: τ) b₁ = (a :: b :: (mergeVal σ b₀ τ b₁).1, (mergeVal σ b₀ τ b₁).2)

                  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 mergeVal (the crux of approximability). #

                    theorem Domain.Neighborhood.Exercise516.SLe_cons2 {p p' : Bool} {ρ ρ' : ExampleB.Str} (c d : Bool) (h : SLe p ρ p' ρ') :
                    SLe p (c :: d :: ρ) p' (c :: d :: ρ')

                    Two equal head bits prepended preserve SLe.

                    theorem Domain.Neighborhood.Exercise516.SLe_cons_inv {b₀ b₀' a : Bool} {σ₀ σ' : ExampleB.Str} (h : SLe b₀ (a :: σ₀) b₀' σ') :
                    ∃ (σ₀' : List Bool), σ' = a :: σ₀' SLe b₀ σ₀ b₀' σ₀'

                    Invert SLe on a cons in the first string: the second string starts with the same head.

                    theorem Domain.Neighborhood.Exercise516.mergeVal_SLe (σ : ExampleB.Str) (b₀ : Bool) (σ' : ExampleB.Str) (b₀' : Bool) (τ : ExampleB.Str) (b₁ : Bool) (τ' : ExampleB.Str) (b₁' : Bool) :
                    SLe b₀ σ b₀' σ'SLe b₁ τ b₁' τ'SLe (mergeVal σ b₀ τ b₁).2 (mergeVal σ b₀ τ b₁).1 (mergeVal σ' b₀' τ' b₁').2 (mergeVal σ' b₀' τ' b₁').1

                    The monotonicity of interleaving. If (b₀, σ) ⊑ (b₀', σ') and (b₁, τ) ⊑ (b₁', τ') then the interleavings are -ordered. The crux that makes merge approximable.

                    theorem Domain.Neighborhood.Exercise516.mergeElem_mono {σ σ' τ τ' : ExampleB.Str} {b₀ b₀' b₁ b₁' : Bool} (h0 : shapeElem b₀ σ shapeElem b₀' σ') (h1 : shapeElem b₁ τ shapeElem b₁' τ') :
                    mergeElem σ b₀ τ b₁ mergeElem σ' b₀' τ' b₁'

                    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. #

                    theorem Domain.Neighborhood.Exercise516.shape_refine {b : Bool} {σ : ExampleB.Str} {P : Set ExampleB.Str} (hP : Example44.memC P) (hsub : P shape b σ) :
                    ∃ (b' : Bool) (σ' : ExampleB.Str), P = shape b' σ' shapeElem b σ shapeElem b' σ'

                    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
                      @[simp]

                      consMap b shifts a tagged string: b·(c, σ) = (c, b :: σ).

                      theorem Domain.Neighborhood.Exercise516.mergeMap_pair (b₀ : Bool) (σ : ExampleB.Str) (b₁ : Bool) (τ : ExampleB.Str) :
                      mergeMap.toElementMap (pair (shapeElem b₀ σ) (shapeElem b₁ τ)) = mergeElem σ b₀ τ 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. #

                      theorem Domain.Neighborhood.Exercise516.prodMap_ext {f g : ApproximableMap (prod Example44.C Example44.C) Example44.C} (h : ∀ (b₀ : Bool) (σ : ExampleB.Str) (b₁ : Bool) (τ : ExampleB.Str), f.toElementMap (pair (shapeElem b₀ σ) (shapeElem b₁ τ)) = g.toElementMap (pair (shapeElem b₀ σ) (shapeElem b₁ τ))) :
                      f = g

                      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).