File size: 7,377 Bytes
e5a97c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import OAI.Combinatorics.MatrixRemoval.HostBodyModes
import OAI.Combinatorics.MatrixRemoval.HostTreeOrder

namespace OAI

/-!
# From increasing body positions to the four node-order inequalities

These lemmas use the actual host roles and tree keys. Each independent
coordinate map reflects the corresponding tree-key order on variable
positions; no mode-specific ordering is assumed.
-/

universe uAlpha uR uC

namespace Problem348.Construction

theorem vertical_plus_node_order {h : ℕ} {α : Type uAlpha} [Preorder α]
    (rowIndex : Position h → α)
    (hkey : ∀ v w : VariablePosition h,
      rowIndex (Sum.inr (Sum.inl v)) < rowIndex (Sum.inr (Sum.inl w)) →
        TreePositions.rowKey h v < TreePositions.rowKey h w)
    {t : Mode h} (hk : kind t = 0) {r₀ r₁ : Position h}
    (hr₀ : rowRole t 0 r₀) (hr₁ : rowRole t 1 r₁)
    (hrow : rowIndex r₀ < rowIndex r₁) :
    positionNode r₀ / 2 ≤ positionNode r₁ := by
  have hkt : kind t < 2 := by omega
  obtain ⟨x, rfl⟩ := rowRole_vertical_variable hkt hr₀
  obtain ⟨y, rfl⟩ := rowRole_vertical_variable hkt hr₁
  have hx : AtLevel (level t) true x := by simpa [rowRole, hk] using hr₀
  have hy : AtLevel (level t - 1) true y := by simpa [rowRole, hk] using hr₁
  have hl : level t - 1 + 1 = level t := by have := level_pos t; omega
  exact (row_plus_lt_iff (hl ▸ hx) hy).mp (hkey x y hrow)

theorem vertical_minus_node_order {h : ℕ} {α : Type uAlpha} [Preorder α]
    (rowIndex : Position h → α)
    (hkey : ∀ v w : VariablePosition h,
      rowIndex (Sum.inr (Sum.inl v)) < rowIndex (Sum.inr (Sum.inl w)) →
        TreePositions.rowKey h v < TreePositions.rowKey h w)
    {t : Mode h} (hk : kind t = 1) {r₀ r₁ : Position h}
    (hr₀ : rowRole t 0 r₀) (hr₁ : rowRole t 1 r₁)
    (hrow : rowIndex r₀ < rowIndex r₁) :
    positionNode r₀ ≤ positionNode r₁ / 2 := by
  have hkt : kind t < 2 := by omega
  obtain ⟨x, rfl⟩ := rowRole_vertical_variable hkt hr₀
  obtain ⟨y, rfl⟩ := rowRole_vertical_variable hkt hr₁
  have hx : AtLevel (level t - 1) false x := by simpa [rowRole, hk] using hr₀
  have hy : AtLevel (level t) false y := by simpa [rowRole, hk] using hr₁
  have hl : level t - 1 + 1 = level t := by have := level_pos t; omega
  exact (row_minus_lt_iff (hl ▸ hy) hx).mp (hkey x y hrow)

theorem horizontal_plus_node_order {h : ℕ} {α : Type uAlpha} [Preorder α]
    (colIndex : Position h → α)
    (hkey : ∀ v w : VariablePosition h,
      colIndex (Sum.inr (Sum.inl v)) < colIndex (Sum.inr (Sum.inl w)) →
        TreePositions.columnKey h v < TreePositions.columnKey h w)
    {t : Mode h} (hklo : 2 ≤ kind t) (hkhi : kind t < 4)
    {c₀ c₁ : Position h} (hc₀ : colRole t 0 c₀) (hc₁ : colRole t 1 c₁)
    (hcol : colIndex c₀ < colIndex c₁) :
    positionNode c₀ ≤ positionNode c₁ / 2 := by
  obtain ⟨x, rfl⟩ := colRole_horizontal_variable hklo hc₀
  obtain ⟨y, rfl⟩ := colRole_horizontal_variable hklo hc₁
  have hkn : ¬ kind t < 2 := by omega
  have hx : AtLevel (level t - 1) true x := by
    simpa [colRole, hkn, hkhi] using hc₀
  have hy : AtLevel (level t) true y := by
    have hy' : AtLevel (level t) true y ∧ node y % 2 = kind t % 2 := by
      simpa [colRole, hkn, hkhi] using hc₁
    exact hy'.1
  have hl : level t - 1 + 1 = level t := by have := level_pos t; omega
  exact (column_plus_lt_iff (hl ▸ hy) hx).mp (hkey x y hcol)

theorem horizontal_minus_node_order {h : ℕ} {α : Type uAlpha} [Preorder α]
    (colIndex : Position h → α)
    (hkey : ∀ v w : VariablePosition h,
      colIndex (Sum.inr (Sum.inl v)) < colIndex (Sum.inr (Sum.inl w)) →
        TreePositions.columnKey h v < TreePositions.columnKey h w)
    {t : Mode h} (hk : 4 ≤ kind t)
    {c₀ c₁ : Position h} (hc₀ : colRole t 0 c₀) (hc₁ : colRole t 1 c₁)
    (hcol : colIndex c₀ < colIndex c₁) :
    positionNode c₀ / 2 ≤ positionNode c₁ := by
  have hklo : 2 ≤ kind t := by omega
  obtain ⟨x, rfl⟩ := colRole_horizontal_variable hklo hc₀
  obtain ⟨y, rfl⟩ := colRole_horizontal_variable hklo hc₁
  have hkn : ¬ kind t < 2 := by omega
  have hkhi : ¬ kind t < 4 := by omega
  have hx : AtLevel (level t) false x := by
    have hx' : AtLevel (level t) false x ∧ node x % 2 = kind t % 2 := by
      simpa [colRole, hkn, hkhi] using hc₀
    exact hx'.1
  have hy : AtLevel (level t - 1) false y := by
    simpa [colRole, hkn, hkhi] using hc₁
  have hl : level t - 1 + 1 = level t := by have := level_pos t; omega
  exact (column_minus_lt_iff (hl ▸ hx) hy).mp (hkey x y hcol)

/-- Increasing positions in the actual two tree orders satisfy precisely the
node-order premise of the exhaustive six-mode localization theorem. -/
theorem bodyNodeOrder_of_ordered {h : ℕ} {R : Type uR} {C : Type uC} [Preorder R] [Preorder C]
    (rowIndex : Position h → R) (colIndex : Position h → C)
    (hrowKey : ∀ v w : VariablePosition h,
      rowIndex (Sum.inr (Sum.inl v)) < rowIndex (Sum.inr (Sum.inl w)) →
        TreePositions.rowKey h v < TreePositions.rowKey h w)
    (hcolKey : ∀ v w : VariablePosition h,
      colIndex (Sum.inr (Sum.inl v)) < colIndex (Sum.inr (Sum.inl w)) →
        TreePositions.columnKey h v < TreePositions.columnKey h w)
    {t : Mode h} {r₀ r₁ c₀ c₁ : Position h}
    (hr₀ : rowRole t 0 r₀) (hr₁ : rowRole t 1 r₁)
    (hc₀ : colRole t 0 c₀) (hc₁ : colRole t 1 c₁)
    (hrow : rowIndex r₀ < rowIndex r₁) (hcol : colIndex c₀ < colIndex c₁) :
    BodyNodeOrder t r₀ r₁ c₀ c₁ := by
  unfold BodyNodeOrder
  split_ifs with hk₀ hk₁ hk₄
  · exact vertical_plus_node_order rowIndex hrowKey hk₀ hr₀ hr₁ hrow
  · exact vertical_minus_node_order rowIndex hrowKey hk₁ hr₀ hr₁ hrow
  · exact horizontal_plus_node_order colIndex hcolKey (by omega) hk₄ hc₀ hc₁ hcol
  · exact horizontal_minus_node_order colIndex hcolKey (by omega) hc₀ hc₁ hcol

/-- The concrete host localization conclusion, with the numerical mode-order
certificate discharged by the constructed key orders and increasing coordinates. -/
theorem host_ordered_body_leaf_diagonal {h : ℕ} {R : Type uR} {C : Type uC}
    [Preorder R] [Preorder C]
    (rowIndex : Position h → R) (colIndex : Position h → C)
    (hrowKey : ∀ v w : VariablePosition h,
      rowIndex (Sum.inr (Sum.inl v)) < rowIndex (Sum.inr (Sum.inl w)) →
        TreePositions.rowKey h v < TreePositions.rowKey h w)
    (hcolKey : ∀ v w : VariablePosition h,
      colIndex (Sum.inr (Sum.inl v)) < colIndex (Sum.inr (Sum.inl w)) →
        TreePositions.columnKey h v < TreePositions.columnKey h w)
    {t : Mode h} {r₀ r₁ c₀ c₁ : Position h}
    (hr₀ : rowRole t 0 r₀) (hr₁ : rowRole t 1 r₁)
    (hc₀ : colRole t 0 c₀) (hc₁ : colRole t 1 c₁)
    (hrow : rowIndex r₀ < rowIndex r₁) (hcol : colIndex c₀ < colIndex c₁)
    (hb : ModeLocalization.IsP (host r₀ c₀) (host r₀ c₁)
      (host r₁ c₀) (host r₁ c₁)) :
    ∃ z : Fin (2 ^ h),
      r₀ = Sum.inr (Sum.inl (Fin.last (2 * h), z)) ∧
      c₀ = Sum.inr (Sum.inl (Fin.last (2 * h), z)) := by
  exact host_body_leaf_diagonal hr₀ hr₁ hc₀ hc₁
    (bodyNodeOrder_of_ordered rowIndex colIndex hrowKey hcolKey hr₀ hr₁ hc₀ hc₁ hrow hcol) hb

end Problem348.Construction

end OAI