While this submission is a draft, it cannot be used by other submissions.

Tilings one exponential up

Lax822549.WideTilings · concepts/Lax822549/WideTilings.lean · lax-822549

definition

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Natural Language Statement

    Definition

    A tile system gives tiles, horizontal and vertical compatibilities, the tiles allowed on the first row and its edges, and accepting tiles. Over an instance of the wide tiling vocabulary, the system tiles the square whose sides are the 2n2^n addresses of the instance; the square tiling problem asks whether that square has a tiling, and the corridor tiling problem whether the corridor of width 2n2^n and unbounded height has one, both on a well-formed instance.

    Concept map
    7 concepts; 3 descendants hidden
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    Lean source view on GitHub

    1import Mathlib.Algebra.BigOperators.Finprod
    2import Mathlib.Data.Set.Finite.Lemmas
    3import Mathlib.Data.Fintype.EquivFin
    4import Mathlib.Data.Set.Card
    5import Mathlib.SetTheory.Cardinal.Finite
    6import Mathlib.Logic.Equiv.Prod
    7import Mathlib.ModelTheory.Order
    8import Mathlib.ModelTheory.Semantics
    9import Mathlib.ModelTheory.Complexity
    10import Mathlib.Tactic.FinCases
    11import Mathlib.Order.PiLex
    12import Mathlib.Data.Prod.Lex
    13import Mathlib.Logic.Equiv.Fin.Basic
    14import Mathlib.Data.Finite.Sigma
    15import Mathlib.Data.Fintype.Lattice
    16import Mathlib.Order.Lattice.Nat
    17import Mathlib.Data.Fintype.Pigeonhole
    18import Mathlib.Dynamics.FixedPoints.Basic
    19import Lax822549.WideMachines
    20import Lax904597.Machines
    21import Lax904597.Problems
    22import Lax485149.Problems
    23
    24/-!
    25---
    26title: Tilings one exponential up
    27type: definition
    28---
    29A tile system gives tiles, horizontal and vertical compatibilities, the
    30tiles allowed on the first row and its edges, and accepting tiles. Over an
    31instance of the wide tiling vocabulary, the system tiles the square whose
    32sides are the 2n2^n addresses of the instance; the square tiling problem
    33asks whether that square has a tiling, and the corridor tiling problem
    34whether the corridor of width 2n2^n and unbounded height has one, both on a
    35well-formed instance.
    36-/
    37
    38namespace Lax822549.WideTilings
    39
    40open Lax822549.WideMachines Lax904597.Machines
    41
    42section Ripple
    43
    44variable {A : Type} [Finite A] {Le : A → A → Prop} {Posn : A → Prop}
    45
    46/-- `p` is a highest position. -/
    47def MaxPos (Le : A → A → Prop) (Posn : A → Prop) (p : A) : Prop :=
    48 Posn p ∧ ∀ q, Posn q → Le q p
    49
    50end Ripple
    51
    52open FirstOrder
    53
    54open Language Structure
    55
    56/-- **A tile system**, read off an instance: the positions with their order,
    57the tiles with their compatibilities, the bottom row and the accepting tiles.
    58As with `TMData`, the record is a plain bundle of
    59predicates, so everything about tilings is stated once and read at whatever
    60structure supplies them. -/
    61structure TileData (A : Type) where
    62 /-- Being a position – a column, and equally a row. -/
    63 Posn : A → Prop
    64 /-- The order on positions. -/
    65 Le : A → A → Prop
    66 /-- Being a tile. -/
    67 Tile : A → Prop
    68 /-- Being an accepting tile. -/
    69 Acc : A → Prop
    70 /-- The right neighbor may carry this tile. -/
    71 Horiz : A → A → Prop
    72 /-- The upper neighbor may carry this tile. -/
    73 Vert : A → A → Prop
    74 /-- The bottom row's cell in this column may carry this tile. -/
    75 First : A → A → Prop
    76 /-- Being a base tile: what a column the description says nothing about
    77 carries in the bottom row. -/
    78 Base : A → Prop
    79 /-- Being a start tile: what the corner of the grid carries. -/
    80 Start : A → Prop
    81 /-- Being a left-edge tile: what the leftmost column may carry. -/
    82 EdgeL : A → Prop
    83 /-- Being a right-edge tile: what the rightmost column may carry. -/
    84 EdgeR : A → Prop
    85
    86namespace TileData
    87
    88variable {A : Type} (T : TileData A)
    89
    90/-- **The tiles the bottom row may carry in a column**: the ones the
    91description names there, and the base tiles in a column it names none. This is
    92`TMData.InitTape`'s device – a description of the row
    93rather than a listing – and it is what lets an expansion carry it. -/
    94def FirstTile (x t : A) : Prop :=
    95 T.First x t ∨ ((∀ u, ¬T.First x u) ∧ T.Base t)
    96
    97/-- **A tiling of the square**: every cell carries a tile, the bottom row is one
    98the description allows, the two edge columns carry tiles allowed there,
    99horizontal and vertical neighbors are compatible, and some cell carries an
    100accepting tile.
    101
    102The two **edge conditions** are what the classical border colors of a tiling
    103problem do. A condition on neighbors says nothing about a column with no
    104neighbor on one side, so without them a tile whose meaning is “something is
    105arriving from the left” could stand in the leftmost column, justified by nothing;
    106a machine drawn as a tiling would then grow a head out of nowhere. -/
    107def IsTiling (τ : A → A → A) : Prop :=
    108 (∀ x y, T.Posn x → T.Posn y → T.Tile (τ x y)) ∧
    109 (∀ x y, T.Posn x → MinPos T.Le T.Posn y →
    110 ((MinPos T.Le T.Posn x → T.Start (τ x y)) ∧
    111 (¬MinPos T.Le T.Posn x → T.FirstTile x (τ x y)))) ∧
    112 (∀ x y, T.Posn y → MinPos T.Le T.Posn x → T.EdgeL (τ x y)) ∧
    113 (∀ x y, T.Posn y → MaxPos T.Le T.Posn x → T.EdgeR (τ x y)) ∧
    114 (∀ x x' y, SuccPos T.Le T.Posn x x' → T.Posn y → T.Horiz (τ x y) (τ x' y)) ∧
    115 (∀ x y y', T.Posn x → SuccPos T.Le T.Posn y y' → T.Vert (τ x y) (τ x y')) ∧
    116 ∃ x y, T.Posn x ∧ T.Posn y ∧ T.Acc (τ x y)
    117
    118/-- **The square is tileable**: some assignment of tiles to cells is a tiling.
    119The assignment is a function on the whole universe – what it does off the grid
    120is not read, so nothing is lost by not restricting it. -/
    121def Tileable : Prop := ∃ τ : A → A → A, T.IsTiling τ
    122
    123/-- **Well-formedness**, folded into the yes-instances exactly as
    124`TMData.WellFormed` is: the order is linear, and there is
    125a position to index the grid by. -/
    126def WellFormed : Prop := IsLinOrd T.Le ∧ ∃ p, T.Posn p
    127
    128open FirstOrder
    129
    130open Language Structure
    131
    132variable {A : Type} (T : TileData A)
    133
    134/-- **A tiling of the corridor up to a given height**: every cell of the strip
    135carries a tile, the bottom row is one the description allows, the two edge
    136columns carry tiles allowed there, neighbors in a row and rows one above the
    137other are compatible, and the top row carries an accepting tile.
    138
    139The height is where a corridor differs from
    140`TileData.IsTiling`: nothing in the instance bounds it,
    141and the tiles above the accepting row are not asked about at all. -/
    142def IsCorridor (h : ℕ) (τ : ℕ → A → A) : Prop :=
    143 (∀ k x, k ≤ h → T.Posn x → T.Tile (τ k x)) ∧
    144 (∀ x, T.Posn x →
    145 ((MinPos T.Le T.Posn x → T.Start (τ 0 x)) ∧
    146 (¬MinPos T.Le T.Posn x → T.FirstTile x (τ 0 x)))) ∧
    147 (∀ k x, k ≤ h → MinPos T.Le T.Posn x → T.EdgeL (τ k x)) ∧
    148 (∀ k x, k ≤ h → MaxPos T.Le T.Posn x → T.EdgeR (τ k x)) ∧
    149 (∀ k x x', k ≤ h → SuccPos T.Le T.Posn x x' → T.Horiz (τ k x) (τ k x')) ∧
    150 (∀ k x, k < h → T.Posn x → T.Vert (τ k x) (τ (k + 1) x)) ∧
    151 ∃ x, T.Posn x ∧ T.Acc (τ h x)
    152
    153/-- **The corridor can be tiled**: some assignment of tiles to its cells is a
    154tiling of it, of some height. -/
    155def CorridorTileable : Prop := ∃ (h : ℕ) (τ : ℕ → A → A), T.IsCorridor h τ
    156
    157end TileData
    158
    159open FirstOrder
    160
    161open FirstOrder.Language
    162
    163/-- Relation symbols of wide tile-system instances: the tiles of
    164`FirstOrder.Language.tiling` with their compatibilities, and the positions and
    165their order replaced by an order on the elements – the digits of an address. -/
    166inductive wtileRel : ℕ → Type
    167 /-- `wtLe x y`: the order on the elements, along which an address is read as a
    168 binary number. -/
    169 | wle : wtileRel 2
    170 /-- `wtDig x`: `x` is a digit – one of the elements the grid's coordinates are
    171 subsets of. -/
    172 | dig : wtileRel 1
    173 /-- `wtTile t`: `t` is a tile. -/
    174 | tile : wtileRel 1
    175 /-- `wtAcc t`: `t` is an accepting tile. -/
    176 | tacc : wtileRel 1
    177 /-- `wtHoriz t t'`: `t'` may stand immediately to the right of `t`. -/
    178 | horiz : wtileRel 2
    179 /-- `wtVert t t'`: `t'` may stand immediately above `t`. -/
    180 | vert : wtileRel 2
    181 /-- `wtFirst x t`: the bottom row's cell of `x` may carry `t`. -/
    182 | first : wtileRel 2
    183 /-- `wtBase t`: `t` is a base tile – what the bottom row carries where the
    184 description says nothing. -/
    185 | base : wtileRel 1
    186 /-- `wtStart t`: `t` is a start tile – what the corner of the grid carries. -/
    187 | tstart : wtileRel 1
    188 /-- `wtEdgeL t`: `t` may stand in the leftmost column. -/
    189 | ledge : wtileRel 1
    190 /-- `wtEdgeR t`: `t` may stand in the rightmost column. -/
    191 | redge : wtileRel 1
    192 deriving DecidableEq
    193
    194/-- The relational vocabulary of wide tile-system instances. -/
    195def wtile : Language :=
    196 ⟨fun _ => Empty, wtileRel⟩
    197
    198instance instIsRelationalWtile : wtile.IsRelational :=
    199 fun _ => (inferInstance : IsEmpty Empty)
    200
    201/-- The order on the elements of the instance. -/
    202abbrev wtLe : wtile.Relations 2 := .wle
    203
    204/-- The digit symbol. -/
    205abbrev wtDig : wtile.Relations 1 := .dig
    206
    207/-- The tile symbol. -/
    208abbrev wtTile : wtile.Relations 1 := .tile
    209
    210/-- The accepting-tile symbol. -/
    211abbrev wtAcc : wtile.Relations 1 := .tacc
    212
    213/-- The horizontal-compatibility symbol. -/
    214abbrev wtHoriz : wtile.Relations 2 := .horiz
    215
    216/-- The vertical-compatibility symbol. -/
    217abbrev wtVert : wtile.Relations 2 := .vert
    218
    219/-- The bottom-row symbol. -/
    220abbrev wtFirst : wtile.Relations 2 := .first
    221
    222/-- The base-tile symbol. -/
    223abbrev wtBase : wtile.Relations 1 := .base
    224
    225/-- The start-tile symbol. -/
    226abbrev wtStart : wtile.Relations 1 := .tstart
    227
    228/-- The left-edge symbol. -/
    229abbrev wtEdgeL : wtile.Relations 1 := .ledge
    230
    231/-- The right-edge symbol. -/
    232abbrev wtEdgeR : wtile.Relations 1 := .redge
    233
    234open FirstOrder
    235
    236open Language Structure
    237
    238section Shorthands
    239
    240variable {A : Type} [wtile.Structure A]
    241
    242/-- The order on the elements. -/
    243def WTLe (a b : A) : Prop := RelMap wtLe ![a, b]
    244
    245/-- Being a digit: one of the elements the grid's coordinates are subsets of. -/
    246def WTDig (a : A) : Prop := RelMap wtDig ![a]
    247
    248/-- Being a tile. -/
    249def WTTile (a : A) : Prop := RelMap wtTile ![a]
    250
    251/-- Being an accepting tile. -/
    252def WTAcc (a : A) : Prop := RelMap wtAcc ![a]
    253
    254/-- Horizontal compatibility. -/
    255def WTHoriz (a b : A) : Prop := RelMap wtHoriz ![a, b]
    256
    257/-- Vertical compatibility. -/
    258def WTVert (a b : A) : Prop := RelMap wtVert ![a, b]
    259
    260/-- The bottom row, at the cell of an element. -/
    261def WTFirst (a b : A) : Prop := RelMap wtFirst ![a, b]
    262
    263/-- Being a base tile. -/
    264def WTBase (a : A) : Prop := RelMap wtBase ![a]
    265
    266/-- Being a start tile. -/
    267def WTStart (a : A) : Prop := RelMap wtStart ![a]
    268
    269/-- Being a left-edge tile: one the leftmost column may carry. -/
    270def WTEdgeL (a : A) : Prop := RelMap wtEdgeL ![a]
    271
    272/-- Being a right-edge tile: one the rightmost column may carry. -/
    273def WTEdgeR (a : A) : Prop := RelMap wtEdgeR ![a]
    274
    275/-- **An element the bottom row is described at**: one whose cell carries a
    276tile. These are the elements the file has cells for. -/
    277def WTHasFirst (a : A) : Prop := ∃ t : A, WTFirst a t
    278
    279end Shorthands
    280
    281section System
    282
    283variable {A : Type} [wtile.Structure A]
    284
    285/-- Being a position: an address is one exactly when it holds digits alone, so
    286the grid is indexed by the subsets of the *marked* part of the instance. That is
    287what leaves the instance room for its tiles: a tile is an element like any
    288other, and only the digits are coordinates. -/
    289def wtpPosn : WPoint A → Prop
    290 | Sum.inl s => ∀ x, s x → WTDig x
    291 | Sum.inr _ => False
    292
    293/-- The order on the universe of the tiling: addresses first, in the
    294binary-number order they inherit from the instance's own order, then the tiles
    295in that same order. -/
    296def wtpLe : WPoint A → WPoint A → Prop
    297 | Sum.inl s, Sum.inl t => WMSetLe WTLe s t
    298 | Sum.inl _, Sum.inr _ => True
    299 | Sum.inr _, Sum.inl _ => False
    300 | Sum.inr x, Sum.inr y => WTLe x y
    301
    302/-- The bottom row: the cell of `x` – the segment `x` cuts among the elements
    303the description names – may carry the tiles of `x`, and every other address a
    304base tile. That is the same device as the register channel's input
    305(`wpInpReg`): a file of cells, not the ruler of all the
    306segments, because a clocked machine's tape is described the same way and that is
    307where this problem's hardness comes from. -/
    308def wtpFirst : WPoint A → WPoint A → Prop
    309 | Sum.inl s, Sum.inr y => ∃ x, WMFileSeg WTLe WTHasFirst s x ∧ WTFirst x y
    310 | _, _ => False
    311
    312variable (A) in
    313/-- **The wide tile system an instance describes**: the tiles read off the
    314instance, the positions being the addresses. -/
    315def wideTileData : TileData (WPoint A) where
    316 Posn := wtpPosn
    317 Le := wtpLe
    318 Tile := wpMark WTTile
    319 Acc := wpMark WTAcc
    320 Horiz := wpAttr WTHoriz
    321 Vert := wpAttr WTVert
    322 First := wtpFirst
    323 Base := wpMark WTBase
    324 Start := wpMark WTStart
    325 EdgeL := wpMark WTEdgeL
    326 EdgeR := wpMark WTEdgeR
    327
    328end System
    329
    330open Lax904597.Problems Lax485149.Problems
    331
    332/-- **Square tiling one exponential up.** -/
    333def WideTiling : DecisionProblem wtile :=
    334 DecisionProblem.ofPred fun A _ => (wideTileData A).WellFormed ∧ (wideTileData A).Tileable
    335
    336/-- **Corridor tiling one exponential up.** -/
    337def WideCorridor : DecisionProblem wtile :=
    338 DecisionProblem.ofPred fun A _ => (wideTileData A).WellFormed ∧ (wideTileData A).CorridorTileable
    339
    340end Lax822549.WideTilings
    341

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above.

    Loading discussion…