Documentation

CslibFrontier.Computability.WangTile.Robinson.Shading.Basic

Red-wire shades and their propagation #

Each red edge of a Robinson quarter carries a light or dark shade. Straight wires and corners preserve shades; crossings require opposite shades. A locally allowed matching assignment therefore respects the parity of each red-graph path, and every rectangular oriented red cycle carries one shade around its boundary.

The coarsening results assume ValidShadeGrid (iterateRefine 2 grid) fine. Existence of such a decoration is established only by the later Canonical/* construction; this module proves preservation conditional on that hypothesis.

Main definitions #

Main results #

References #

The shading rules are after [JV20], §3.3, Figures 17–18 (manuscript pp. 24, 26–28). Prior formalization: lean-wang, revision 64268a3, modules Closed104.RedShades, RedShadePaths, RedShadeCycles and RedShadeGraph, RedShadeGraphCoarsening, SignalCorridors, Signals and ShadedSignals. These are local decoration and propagation steps of the corrected Robinson scaffold, not the seed-removal theorem.

The two shades of a red wire.

Instances For

    Both shades, in light/dark order for finite enumeration.

    @[simp]

    Every shade occurs in the finite enumeration.

    @[instance_reducible]

    The two wire shades form a finite type.

    Exchange the two red-wire shades.

    @[simp]

    Exchanging the shade twice is the identity.

    theorem Cslib.WangTile.Robinson.Shade.eq_opposite_of_ne {first second : Shade} (hne : first ≠ second) :
    second = first.opposite

    Distinct shades are opposites.

    Optional shade carried by each edge of one quarter tile.

    Every four-edge shade state, in west/east/south/north order.

    @[simp]

    Every four-edge shade state occurs in the enumeration.

    def Cslib.WangTile.Robinson.allowedFor (component : Thick) (quadrant : Quadrant) (state : ShadeState) :

    Local rule with the thick component made explicit for proof reuse.

    Swap the two wire shades without changing port incidence.

    theorem Cslib.WangTile.Robinson.ShadeState.flip_allowed {component : Thick} {quadrant : Quadrant} {state : ShadeState} (allowed : allowedFor component quadrant state = true) :
    allowedFor component quadrant state.flip = true

    Swapping both shades preserves the local shade rules.

    structure Cslib.WangTile.Robinson.Allowed (component : Thick) (quadrant : Quadrant) (state : ShadeState) :

    The incidence, transmission and crossing conditions of one allowed quarter.

    theorem Cslib.WangTile.Robinson.allowedFor_iff {component : Thick} {quadrant : Quadrant} {state : ShadeState} :
    allowedFor component quadrant state = true ↔ Allowed component quadrant state

    The Boolean local checker expresses exactly the named shading conditions.

    Local red-path incidence, propagation, corner, and crossing rules.

    structure Cslib.WangTile.Robinson.ValidShadeGrid (indexGrid : ℕ → ℕ → Index) (stateGrid : ℕ → ℕ → ShadeState) :

    A locally allowed, edge-matching shade assignment over a quarter grid.

    • allowed (x y : ℕ) : locallyAllowed { index := indexGrid (x / 2) (y / 2), quadrant := quadrantAt x y } (stateGrid x y) = true

      Every quarter satisfies the local incidence and shade rules.

    • hmatch (x y : ℕ) : (stateGrid x y).east = (stateGrid (x + 1) y).west

      Adjacent quarters agree on horizontal shared edges.

    • vmatch (x y : ℕ) : (stateGrid x y).north = (stateGrid x (y + 1)).south

      Adjacent quarters agree on vertical shared edges.

    theorem Cslib.WangTile.Robinson.ValidShadeGrid.rules {indexGrid : ℕ → ℕ → Index} {stateGrid : ℕ → ℕ → ShadeState} (valid : ValidShadeGrid indexGrid stateGrid) (x y : ℕ) :
    Allowed (componentAt indexGrid x y) (quadrantAt x y) (stateGrid x y)

    Read the named local shading conditions at any quarter of a valid grid.

    theorem Cslib.WangTile.Robinson.value_between {α : Type u_1} {β : Type u_2} (state : ℕ → α) (outgoing incoming : α → β) {start finish : ℕ} (hlt : start < finish) (hmatch : ∀ (position : ℕ), start ≤ position → position < finish → outgoing (state position) = incoming (state (position + 1))) (htransmit : ∀ (position : ℕ), start < position → position < finish → incoming (state position) = outgoing (state position)) :
    outgoing (state start) = incoming (state finish)

    Matching and transmission on an interval identify its two boundary values.

    Inward quarter coordinate of the west boundary.

    Inward quarter coordinate of the east boundary.

    Inward quarter coordinate of the south boundary.

    Inward quarter coordinate of the north boundary.

    theorem Cslib.WangTile.Robinson.componentAt_double_add (grid : ℕ → ℕ → Index) (x y dx dy : ℕ) (hdx : dx < 2) (hdy : dy < 2) :
    componentAt grid (2 * x + dx) (2 * y + dy) = indexThick (grid x y)

    Every quarter of a parent has that parent’s thick component.

    The inward south quarter has its north-facing bit set.

    The inward north quarter has its south-facing bit set.

    The inward west quarter has its east-facing bit set.

    The inward east quarter has its west-facing bit set.

    theorem Cslib.WangTile.Robinson.CycleOn.southwest_corner {grid : ℕ → ℕ → Index} {west east south north : ℕ} (cycle : CycleOn grid west east south north) :

    The inward southwest quarter joins the east and north red edges.

    theorem Cslib.WangTile.Robinson.CycleOn.southeast_corner {grid : ℕ → ℕ → Index} {west east south north : ℕ} (cycle : CycleOn grid west east south north) :

    The inward southeast quarter joins the west and north red edges.

    theorem Cslib.WangTile.Robinson.CycleOn.northeast_corner {grid : ℕ → ℕ → Index} {west east south north : ℕ} (cycle : CycleOn grid west east south north) :

    The inward northeast quarter joins the west and south red edges.

    theorem Cslib.WangTile.Robinson.CycleOn.northwest_corner {grid : ℕ → ℕ → Index} {west east south north : ℕ} (cycle : CycleOn grid west east south north) :

    The inward northwest quarter joins the east and south red edges.

    theorem Cslib.WangTile.Robinson.CycleOn.south_path {grid : ℕ → ℕ → Index} {west east south north qx : ℕ} (cycle : CycleOn grid west east south north) (hwest : quarterWest west < qx) (heast : qx < quarterEast east) :

    Every strict interior quarter on the south side carries a horizontal wire.

    theorem Cslib.WangTile.Robinson.CycleOn.north_path {grid : ℕ → ℕ → Index} {west east south north qx : ℕ} (cycle : CycleOn grid west east south north) (hwest : quarterWest west < qx) (heast : qx < quarterEast east) :

    Every strict interior quarter on the north side carries a horizontal wire.

    theorem Cslib.WangTile.Robinson.CycleOn.west_path {grid : ℕ → ℕ → Index} {west east south north qy : ℕ} (cycle : CycleOn grid west east south north) (hsouth : quarterSouth south < qy) (hnorth : qy < quarterNorth north) :

    Every strict interior quarter on the west side carries a vertical wire.

    theorem Cslib.WangTile.Robinson.CycleOn.east_path {grid : ℕ → ℕ → Index} {west east south north qy : ℕ} (cycle : CycleOn grid west east south north) (hsouth : quarterSouth south < qy) (hnorth : qy < quarterNorth north) :

    Every strict interior quarter on the east side carries a vertical wire.

    structure Cslib.WangTile.Robinson.CycleShade (stateGrid : ℕ → ℕ → ShadeState) (west east south north : ℕ) (shade : Shade) :

    Uniform shade at the four inward quarter corners of an arbitrary board.

    theorem Cslib.WangTile.Robinson.CycleOn.cycleShade {grid : ℕ → ℕ → Index} {stateGrid : ℕ → ℕ → ShadeState} {west east south north : ℕ} (cycle : CycleOn grid west east south north) (valid : ValidShadeGrid grid stateGrid) (shade : Shade) (hshade : (stateGrid (quarterWest west) (quarterSouth south)).east = some shade) :
    CycleShade stateGrid west east south north shade

    A shade on one edge of any oriented board propagates to every corner.

    theorem Cslib.WangTile.Robinson.CycleOn.exists_cycleShade {grid : ℕ → ℕ → Index} {stateGrid : ℕ → ℕ → ShadeState} {west east south north : ℕ} (cycle : CycleOn grid west east south north) (valid : ValidShadeGrid grid stateGrid) :
    ∃ (shade : Shade), CycleShade stateGrid west east south north shade

    Every oriented red board has one uniform light/dark corner shade.

    theorem Cslib.WangTile.Robinson.CycleShade.south_at {grid : ℕ → ℕ → Index} {stateGrid : ℕ → ℕ → ShadeState} {west east south north : ℕ} {shade : Shade} (shaded : CycleShade stateGrid west east south north shade) (cycle : CycleOn grid west east south north) (valid : ValidShadeGrid grid stateGrid) {qx : ℕ} (hwest : quarterWest west < qx) (heast : qx < quarterEast east) :
    (stateGrid qx (quarterSouth south)).west = some shade ∧ (stateGrid qx (quarterSouth south)).east = some shade

    The south side of a uniformly shaded cycle carries its corner shade.

    theorem Cslib.WangTile.Robinson.CycleShade.north_at {grid : ℕ → ℕ → Index} {stateGrid : ℕ → ℕ → ShadeState} {west east south north : ℕ} {shade : Shade} (shaded : CycleShade stateGrid west east south north shade) (cycle : CycleOn grid west east south north) (valid : ValidShadeGrid grid stateGrid) {qx : ℕ} (hwest : quarterWest west < qx) (heast : qx < quarterEast east) :
    (stateGrid qx (quarterNorth north)).west = some shade ∧ (stateGrid qx (quarterNorth north)).east = some shade

    The north side of a uniformly shaded cycle carries its corner shade.

    theorem Cslib.WangTile.Robinson.CycleShade.west_at {grid : ℕ → ℕ → Index} {stateGrid : ℕ → ℕ → ShadeState} {west east south north : ℕ} {shade : Shade} (shaded : CycleShade stateGrid west east south north shade) (cycle : CycleOn grid west east south north) (valid : ValidShadeGrid grid stateGrid) {qy : ℕ} (hsouth : quarterSouth south < qy) (hnorth : qy < quarterNorth north) :
    (stateGrid (quarterWest west) qy).south = some shade ∧ (stateGrid (quarterWest west) qy).north = some shade

    The west side of a uniformly shaded cycle carries its corner shade.

    theorem Cslib.WangTile.Robinson.CycleShade.east_at {grid : ℕ → ℕ → Index} {stateGrid : ℕ → ℕ → ShadeState} {west east south north : ℕ} {shade : Shade} (shaded : CycleShade stateGrid west east south north shade) (cycle : CycleOn grid west east south north) (valid : ValidShadeGrid grid stateGrid) {qy : ℕ} (hsouth : quarterSouth south < qy) (hnorth : qy < quarterNorth north) :
    (stateGrid (quarterEast east) qy).south = some shade ∧ (stateGrid (quarterEast east) qy).north = some shade

    The east side of a uniformly shaded cycle carries its corner shade.

    def Cslib.WangTile.Robinson.value (stateGrid : ℕ → ℕ → ShadeState) (port : Port) :

    Shade at the indicated edge port.

    theorem Cslib.WangTile.Robinson.value_isSome_eq_portPresent_of_allowed {grid : ℕ → ℕ → Index} {shadeGrid : ℕ → ℕ → ShadeState} (port : Port) (allowed : locallyAllowed { index := grid (port.x / 2) (port.y / 2), quadrant := quadrantAt port.x port.y } (shadeGrid port.x port.y) = true) :
    (value shadeGrid port).isSome = portPresent grid port

    A locally allowed shade state has exactly the red-graph incidence at each port.

    theorem Cslib.WangTile.Robinson.value_isSome_eq_portPresent {grid : ℕ → ℕ → Index} {shadeGrid : ℕ → ℕ → ShadeState} (valid : ValidShadeGrid grid shadeGrid) (port : Port) :
    (value shadeGrid port).isSome = portPresent grid port

    Allowed shade states have exactly the red-graph incidence.

    def Cslib.WangTile.Robinson.Related (parity : Bool) (first second : Option Shade) :

    Even parity means equal shades; odd parity means opposite present shades.

    theorem Cslib.WangTile.Robinson.Related.symm {parity : Bool} {first second : Option Shade} (relation : Related parity first second) :
    Related parity second first

    Equality or opposition of present shades is symmetric.

    theorem Cslib.WangTile.Robinson.Related.right_unique {parity : Bool} {a b c : Option Shade} (hab : Related parity a b) (hac : Related parity a c) :
    b = c

    A source shade and path parity uniquely determine the target shade.

    theorem Cslib.WangTile.Robinson.Related.trans {first second third : Option Shade} {firstParity secondParity : Bool} (firstRelation : Related firstParity first second) (secondRelation : Related secondParity second third) :
    Related (firstParity ^^ secondParity) first third

    Shade relations compose by taking the exclusive-or of their parities.

    theorem Cslib.WangTile.Robinson.Link.sound {indexGrid : ℕ → ℕ → Index} {stateGrid : ℕ → ℕ → ShadeState} (valid : ValidShadeGrid indexGrid stateGrid) {first second : Port} {parity : Bool} (link : Link indexGrid first second parity) :
    Related parity (value stateGrid first) (value stateGrid second)

    Each graph link enforces the corresponding shade parity in a valid grid.

    A parity-consistent assignment to all red-graph ports. Incidence is part of the data because match links exist independently of whether the shared edge carries a red wire.

    • label : Port → Option Shade

      Optional shade at each quarter-edge port.

    • present (port : Port) : (self.label port).isSome = portPresent indexGrid port

      Labels are present exactly on the geometrically prescribed red edges.

    • related {first second : Port} {parity : Bool} : Link indexGrid first second parity → Related parity (self.label first) (self.label second)

      Every local connection respects its crossing parity.

    def Cslib.WangTile.Robinson.ValidPortLabeling.stateGrid {indexGrid : ℕ → ℕ → Index} (labeling : ValidPortLabeling indexGrid) :

    Regroup four labeled ports into the corresponding quarter shade state.

    theorem Cslib.WangTile.Robinson.ValidPortLabeling.validShadeGrid {indexGrid : ℕ → ℕ → Index} (labeling : ValidPortLabeling indexGrid) :
    ValidShadeGrid indexGrid labeling.stateGrid

    Port incidence and parity-link consistency are exactly the local shade tile and edge-matching rules.

    theorem Cslib.WangTile.Robinson.Path.sound {indexGrid : ℕ → ℕ → Index} {stateGrid : ℕ → ℕ → ShadeState} (valid : ValidShadeGrid indexGrid stateGrid) {first second : Port} {parity : Bool} (path : Path indexGrid first second parity) :
    Related parity (value stateGrid first) (value stateGrid second)

    The parity of a red-graph path determines the relation between its endpoint shades.

    theorem Cslib.WangTile.Robinson.BoundedPath.sound {indexGrid : ℕ → ℕ → Index} {stateGrid : ℕ → ℕ → ShadeState} {width height : ℕ} (allowed : ∀ (x y : ℕ), x < width → y < height → locallyAllowed { index := indexGrid (x / 2) (y / 2), quadrant := quadrantAt x y } (stateGrid x y) = true) (hmatch : ∀ (x y : ℕ), x + 1 < width → y < height → (stateGrid x y).east = (stateGrid (x + 1) y).west) (vmatch : ∀ (x y : ℕ), x < width → y + 1 < height → (stateGrid x y).north = (stateGrid x (y + 1)).south) {first second : Port} {parity : Bool} (path : BoundedPath indexGrid width height first second parity) :
    Related parity (value stateGrid first) (value stateGrid second)

    A bounded red-wire path relates its endpoint shades using only local validity and matching within the bounding rectangle.

    Which side of a vertical red border is the board interior.

    Which side of a horizontal red border is the board interior.

    Vertical red boundary through a quarter, if any.

    Horizontal red boundary through a quarter, if any.

    Shade of the vertical red path through a quarter, if present.

    Shade of the horizontal red path through a quarter, if present.

    Selected vertical-border rule with the component made explicit.

    Selected horizontal-border rule with the component made explicit.

    Pull the four shades of a coarse quarter from its refined boundary ports.

    @[simp]
    theorem Cslib.WangTile.Robinson.value_coarsen (fine : ℕ → ℕ → ShadeState) (port : Port) :
    value (coarsen fine) port = value fine (refinedPort port)

    A coarsened port reads its corresponding refined port.

    theorem Cslib.WangTile.Robinson.ValidShadeGrid.coarsen {grid : ℕ → ℕ → Index} {fine : ℕ → ℕ → ShadeState} (hfine : ValidShadeGrid (iterateRefine 2 grid) fine) :

    Coarsening a valid twice-substituted assignment preserves all shade rules and matches.

    theorem Cslib.WangTile.Robinson.CycleShade.coarsen {grid : ℕ → ℕ → Index} {fine : ℕ → ℕ → ShadeState} {west east south north : ℕ} {shade : Shade} (hfine : ValidShadeGrid (iterateRefine 2 grid) fine) (cycle : CycleOn grid west east south north) (shaded : CycleShade fine (4 * west) (4 * east) (4 * south) (4 * north) shade) :
    CycleShade (Robinson.coarsen fine) west east south north shade

    A uniformly shaded refined cycle induces the same shade on its coarse ancestor.