Sync from openai/math@faee2cf485a8 (part 2)
Browse files- lean/ComparatorChallenges/FourierLLogL.json +14 -14
- lean/ComparatorChallenges/FourierLLogL.lean +24 -24
- lean/ComparatorChallenges/HadwigerCounterexample.json +15 -15
- lean/ComparatorChallenges/HadwigerCounterexample.lean +56 -56
- lean/ComparatorChallenges/HoneycombBridgeMassSupport.json +14 -14
- lean/ComparatorChallenges/HoneycombBridgeMassSupport.lean +78 -78
- lean/ComparatorChallenges/LogspaceEquality.json +35 -35
- lean/ComparatorChallenges/LogspaceEquality.lean +142 -142
- lean/ComparatorChallenges/OneTapeSpace.json +15 -15
- lean/ComparatorChallenges/OneTapeSpace.lean +275 -275
lean/ComparatorChallenges/FourierLLogL.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
| 1 |
-
{
|
| 2 |
-
"challenge_module": "ComparatorChallenges.FourierLLogL",
|
| 3 |
-
"solution_module": "OAI.Analysis.FourierLLogL.PaperMain",
|
| 4 |
-
"theorem_names": [
|
| 5 |
-
"OAI.FourierLLogL.paperMain"
|
| 6 |
-
],
|
| 7 |
-
"definition_names": [],
|
| 8 |
-
"permitted_axioms": [
|
| 9 |
-
"propext",
|
| 10 |
-
"Quot.sound",
|
| 11 |
-
"Classical.choice"
|
| 12 |
-
],
|
| 13 |
-
"enable_nanoda": false
|
| 14 |
-
}
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"challenge_module": "ComparatorChallenges.FourierLLogL",
|
| 3 |
+
"solution_module": "OAI.Analysis.FourierLLogL.PaperMain",
|
| 4 |
+
"theorem_names": [
|
| 5 |
+
"OAI.FourierLLogL.paperMain"
|
| 6 |
+
],
|
| 7 |
+
"definition_names": [],
|
| 8 |
+
"permitted_axioms": [
|
| 9 |
+
"propext",
|
| 10 |
+
"Quot.sound",
|
| 11 |
+
"Classical.choice"
|
| 12 |
+
],
|
| 13 |
+
"enable_nanoda": false
|
| 14 |
+
}
|
lean/ComparatorChallenges/FourierLLogL.lean
CHANGED
|
@@ -1,24 +1,24 @@
|
|
| 1 |
-
import Mathlib
|
| 2 |
-
|
| 3 |
-
open MeasureTheory Filter
|
| 4 |
-
open scoped BigOperators Topology
|
| 5 |
-
|
| 6 |
-
namespace OAI.FourierLLogL
|
| 7 |
-
|
| 8 |
-
instance circlePeriod_pos : Fact (0 < 2 * Real.pi) :=
|
| 9 |
-
⟨mul_pos (by norm_num) Real.pi_pos⟩
|
| 10 |
-
|
| 11 |
-
/-- Almost-everywhere convergence of all symmetric Fourier partial sums in L log L. -/
|
| 12 |
-
theorem paperMain (f : AddCircle (2 * Real.pi) → ℂ)
|
| 13 |
-
(hfm : AEStronglyMeasurable f AddCircle.haarAddCircle)
|
| 14 |
-
(hfi : Integrable (fun x ↦ ‖f x‖ * Real.log (2 + ‖f x‖))
|
| 15 |
-
AddCircle.haarAddCircle) :
|
| 16 |
-
∃ E : Set (AddCircle (2 * Real.pi)),
|
| 17 |
-
MeasurableSet E ∧ AddCircle.haarAddCircle E = 0 ∧ ∀ x ∉ E,
|
| 18 |
-
Tendsto
|
| 19 |
-
(fun N : ℕ ↦
|
| 20 |
-
∑ k ∈ Finset.Icc (-(N : ℤ)) (N : ℤ), fourierCoeff f k * fourier k x)
|
| 21 |
-
atTop (𝓝 (f x)) := by
|
| 22 |
-
sorry
|
| 23 |
-
|
| 24 |
-
end OAI.FourierLLogL
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
open MeasureTheory Filter
|
| 4 |
+
open scoped BigOperators Topology
|
| 5 |
+
|
| 6 |
+
namespace OAI.FourierLLogL
|
| 7 |
+
|
| 8 |
+
instance circlePeriod_pos : Fact (0 < 2 * Real.pi) :=
|
| 9 |
+
⟨mul_pos (by norm_num) Real.pi_pos⟩
|
| 10 |
+
|
| 11 |
+
/-- Almost-everywhere convergence of all symmetric Fourier partial sums in L log L. -/
|
| 12 |
+
theorem paperMain (f : AddCircle (2 * Real.pi) → ℂ)
|
| 13 |
+
(hfm : AEStronglyMeasurable f AddCircle.haarAddCircle)
|
| 14 |
+
(hfi : Integrable (fun x ↦ ‖f x‖ * Real.log (2 + ‖f x‖))
|
| 15 |
+
AddCircle.haarAddCircle) :
|
| 16 |
+
∃ E : Set (AddCircle (2 * Real.pi)),
|
| 17 |
+
MeasurableSet E ∧ AddCircle.haarAddCircle E = 0 ∧ ∀ x ∉ E,
|
| 18 |
+
Tendsto
|
| 19 |
+
(fun N : ℕ ↦
|
| 20 |
+
∑ k ∈ Finset.Icc (-(N : ℤ)) (N : ℤ), fourierCoeff f k * fourier k x)
|
| 21 |
+
atTop (𝓝 (f x)) := by
|
| 22 |
+
sorry
|
| 23 |
+
|
| 24 |
+
end OAI.FourierLLogL
|
lean/ComparatorChallenges/HadwigerCounterexample.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
| 1 |
-
{
|
| 2 |
-
"challenge_module": "ComparatorChallenges.HadwigerCounterexample",
|
| 3 |
-
"solution_module": "OAI.Combinatorics.HadwigerCounterexample.Main",
|
| 4 |
-
"theorem_names": [
|
| 5 |
-
"OAI.HadwigerCounterexample.exists_counterexamples",
|
| 6 |
-
"OAI.HadwigerCounterexample.not_hadwiger_conjecture"
|
| 7 |
-
],
|
| 8 |
-
"definition_names": [],
|
| 9 |
-
"permitted_axioms": [
|
| 10 |
-
"propext",
|
| 11 |
-
"Quot.sound",
|
| 12 |
-
"Classical.choice"
|
| 13 |
-
],
|
| 14 |
-
"enable_nanoda": false
|
| 15 |
-
}
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"challenge_module": "ComparatorChallenges.HadwigerCounterexample",
|
| 3 |
+
"solution_module": "OAI.Combinatorics.HadwigerCounterexample.Main",
|
| 4 |
+
"theorem_names": [
|
| 5 |
+
"OAI.HadwigerCounterexample.exists_counterexamples",
|
| 6 |
+
"OAI.HadwigerCounterexample.not_hadwiger_conjecture"
|
| 7 |
+
],
|
| 8 |
+
"definition_names": [],
|
| 9 |
+
"permitted_axioms": [
|
| 10 |
+
"propext",
|
| 11 |
+
"Quot.sound",
|
| 12 |
+
"Classical.choice"
|
| 13 |
+
],
|
| 14 |
+
"enable_nanoda": false
|
| 15 |
+
}
|
lean/ComparatorChallenges/HadwigerCounterexample.lean
CHANGED
|
@@ -1,56 +1,56 @@
|
|
| 1 |
-
import Mathlib
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
namespace HadwigerMatching
|
| 6 |
-
|
| 7 |
-
universe u
|
| 8 |
-
variable {V : Type u}
|
| 9 |
-
|
| 10 |
-
def IsTouchingMatching (G : SimpleGraph V) (M : Finset (Finset V)) : Prop :=
|
| 11 |
-
(∀ e ∈ M, e.card = 2 ∧ G.IsClique (e : Set V)) ∧
|
| 12 |
-
(∀ e ∈ M, ∀ f ∈ M, e ≠ f → Disjoint e f) ∧
|
| 13 |
-
(∀ e ∈ M, ∀ f ∈ M, e ≠ f →
|
| 14 |
-
∃ v ∈ e, ∃ w ∈ f, G.Adj v w)
|
| 15 |
-
|
| 16 |
-
noncomputable def connectedMatchingNumber (G : SimpleGraph V) : ℕ :=
|
| 17 |
-
sSup {n : ℕ | ∃ M : Finset (Finset V), IsTouchingMatching G M ∧ M.card = n}
|
| 18 |
-
|
| 19 |
-
end HadwigerMatching
|
| 20 |
-
|
| 21 |
-
namespace LinearListHadwiger
|
| 22 |
-
|
| 23 |
-
def HasCliqueMinor {V : Type} (G : SimpleGraph V) (t : ℕ) : Prop :=
|
| 24 |
-
∃ B : Fin t → Set V,
|
| 25 |
-
(∀ i, (G.induce (B i)).Connected) ∧
|
| 26 |
-
(∀ i j, i ≠ j → Disjoint (B i) (B j)) ∧
|
| 27 |
-
(∀ i j, i ≠ j → ∃ v ∈ B i, ∃ w ∈ B j, G.Adj v w)
|
| 28 |
-
|
| 29 |
-
noncomputable def hadwigerNumber {V : Type} (G : SimpleGraph V) : ℕ :=
|
| 30 |
-
sSup {t : ℕ | HasCliqueMinor G t}
|
| 31 |
-
|
| 32 |
-
end LinearListHadwiger
|
| 33 |
-
|
| 34 |
-
namespace HadwigerCounterexample
|
| 35 |
-
|
| 36 |
-
open HadwigerMatching LinearListHadwiger
|
| 37 |
-
|
| 38 |
-
theorem exists_counterexamples (M : ℕ) : ∃ m : ℕ, max M 5 ≤ m ∧
|
| 39 |
-
∃ G : SimpleGraph (Fin m), G.indepNum ≤ 2 ∧
|
| 40 |
-
(connectedMatchingNumber G : ℚ) < (m : ℚ) / 100 ∧
|
| 41 |
-
(hadwigerNumber G : ℚ) < 26 * (m : ℚ) / 75 + 2 / 3 ∧
|
| 42 |
-
26 * (m : ℚ) / 75 + 2 / 3 < (m : ℚ) / 2 ∧
|
| 43 |
-
(m : ℚ) / 2 ≤ (G.chromaticNumber.toNat : ℚ) ∧
|
| 44 |
-
hadwigerNumber G < G.chromaticNumber.toNat ∧
|
| 45 |
-
G.chromaticNumber ≠ ⊤ ∧
|
| 46 |
-
G.chromaticNumber = ↑(G.chromaticNumber.toNat) := by
|
| 47 |
-
sorry
|
| 48 |
-
|
| 49 |
-
theorem not_hadwiger_conjecture :
|
| 50 |
-
¬ (∀ (m : ℕ) (G : SimpleGraph (Fin m)),
|
| 51 |
-
G.chromaticNumber ≤ ↑(hadwigerNumber G)) := by
|
| 52 |
-
sorry
|
| 53 |
-
|
| 54 |
-
end HadwigerCounterexample
|
| 55 |
-
|
| 56 |
-
end OAI
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace HadwigerMatching
|
| 6 |
+
|
| 7 |
+
universe u
|
| 8 |
+
variable {V : Type u}
|
| 9 |
+
|
| 10 |
+
def IsTouchingMatching (G : SimpleGraph V) (M : Finset (Finset V)) : Prop :=
|
| 11 |
+
(∀ e ∈ M, e.card = 2 ∧ G.IsClique (e : Set V)) ∧
|
| 12 |
+
(∀ e ∈ M, ∀ f ∈ M, e ≠ f → Disjoint e f) ∧
|
| 13 |
+
(∀ e ∈ M, ∀ f ∈ M, e ≠ f →
|
| 14 |
+
∃ v ∈ e, ∃ w ∈ f, G.Adj v w)
|
| 15 |
+
|
| 16 |
+
noncomputable def connectedMatchingNumber (G : SimpleGraph V) : ℕ :=
|
| 17 |
+
sSup {n : ℕ | ∃ M : Finset (Finset V), IsTouchingMatching G M ∧ M.card = n}
|
| 18 |
+
|
| 19 |
+
end HadwigerMatching
|
| 20 |
+
|
| 21 |
+
namespace LinearListHadwiger
|
| 22 |
+
|
| 23 |
+
def HasCliqueMinor {V : Type} (G : SimpleGraph V) (t : ℕ) : Prop :=
|
| 24 |
+
∃ B : Fin t → Set V,
|
| 25 |
+
(∀ i, (G.induce (B i)).Connected) ∧
|
| 26 |
+
(∀ i j, i ≠ j → Disjoint (B i) (B j)) ∧
|
| 27 |
+
(∀ i j, i ≠ j → ∃ v ∈ B i, ∃ w ∈ B j, G.Adj v w)
|
| 28 |
+
|
| 29 |
+
noncomputable def hadwigerNumber {V : Type} (G : SimpleGraph V) : ℕ :=
|
| 30 |
+
sSup {t : ℕ | HasCliqueMinor G t}
|
| 31 |
+
|
| 32 |
+
end LinearListHadwiger
|
| 33 |
+
|
| 34 |
+
namespace HadwigerCounterexample
|
| 35 |
+
|
| 36 |
+
open HadwigerMatching LinearListHadwiger
|
| 37 |
+
|
| 38 |
+
theorem exists_counterexamples (M : ℕ) : ∃ m : ℕ, max M 5 ≤ m ∧
|
| 39 |
+
∃ G : SimpleGraph (Fin m), G.indepNum ≤ 2 ∧
|
| 40 |
+
(connectedMatchingNumber G : ℚ) < (m : ℚ) / 100 ∧
|
| 41 |
+
(hadwigerNumber G : ℚ) < 26 * (m : ℚ) / 75 + 2 / 3 ∧
|
| 42 |
+
26 * (m : ℚ) / 75 + 2 / 3 < (m : ℚ) / 2 ∧
|
| 43 |
+
(m : ℚ) / 2 ≤ (G.chromaticNumber.toNat : ℚ) ∧
|
| 44 |
+
hadwigerNumber G < G.chromaticNumber.toNat ∧
|
| 45 |
+
G.chromaticNumber ≠ ⊤ ∧
|
| 46 |
+
G.chromaticNumber = ↑(G.chromaticNumber.toNat) := by
|
| 47 |
+
sorry
|
| 48 |
+
|
| 49 |
+
theorem not_hadwiger_conjecture :
|
| 50 |
+
¬ (∀ (m : ℕ) (G : SimpleGraph (Fin m)),
|
| 51 |
+
G.chromaticNumber ≤ ↑(hadwigerNumber G)) := by
|
| 52 |
+
sorry
|
| 53 |
+
|
| 54 |
+
end HadwigerCounterexample
|
| 55 |
+
|
| 56 |
+
end OAI
|
lean/ComparatorChallenges/HoneycombBridgeMassSupport.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
| 1 |
-
{
|
| 2 |
-
"challenge_module": "ComparatorChallenges.HoneycombBridgeMassSupport",
|
| 3 |
-
"solution_module": "OAI.Combinatorics.HoneycombChords.BridgeMass",
|
| 4 |
-
"theorem_names": [
|
| 5 |
-
"OAI.CriticalHoneycomb.finiteBridgeMassEstimate"
|
| 6 |
-
],
|
| 7 |
-
"definition_names": [],
|
| 8 |
-
"permitted_axioms": [
|
| 9 |
-
"propext",
|
| 10 |
-
"Quot.sound",
|
| 11 |
-
"Classical.choice"
|
| 12 |
-
],
|
| 13 |
-
"enable_nanoda": false
|
| 14 |
-
}
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"challenge_module": "ComparatorChallenges.HoneycombBridgeMassSupport",
|
| 3 |
+
"solution_module": "OAI.Combinatorics.HoneycombChords.BridgeMass",
|
| 4 |
+
"theorem_names": [
|
| 5 |
+
"OAI.CriticalHoneycomb.finiteBridgeMassEstimate"
|
| 6 |
+
],
|
| 7 |
+
"definition_names": [],
|
| 8 |
+
"permitted_axioms": [
|
| 9 |
+
"propext",
|
| 10 |
+
"Quot.sound",
|
| 11 |
+
"Classical.choice"
|
| 12 |
+
],
|
| 13 |
+
"enable_nanoda": false
|
| 14 |
+
}
|
lean/ComparatorChallenges/HoneycombBridgeMassSupport.lean
CHANGED
|
@@ -1,78 +1,78 @@
|
|
| 1 |
-
import Mathlib
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
namespace CriticalHoneycomb
|
| 6 |
-
open scoped ENNReal
|
| 7 |
-
|
| 8 |
-
abbrev Center := ℤ × ℤ × Bool
|
| 9 |
-
|
| 10 |
-
def up (i j : ℤ) : Center := (i, j, true)
|
| 11 |
-
def down (i j : ℤ) : Center := (i, j, false)
|
| 12 |
-
|
| 13 |
-
/-- Adjacency across a full triangular edge. -/
|
| 14 |
-
def Adj (v w : Center) : Prop :=
|
| 15 |
-
if v.2.2 then
|
| 16 |
-
w.2.2 = false ∧ ((w.1 = v.1 ∧ w.2.1 = v.2.1) ∨
|
| 17 |
-
(w.1 = v.1 ∧ w.2.1 = v.2.1 - 1) ∨
|
| 18 |
-
(w.1 = v.1 - 1 ∧ w.2.1 = v.2.1))
|
| 19 |
-
else
|
| 20 |
-
w.2.2 = true ∧ ((w.1 = v.1 ∧ w.2.1 = v.2.1) ∨
|
| 21 |
-
(w.1 = v.1 ∧ w.2.1 = v.2.1 + 1) ∨
|
| 22 |
-
(w.1 = v.1 + 1 ∧ w.2.1 = v.2.1))
|
| 23 |
-
|
| 24 |
-
noncomputable def rowSpacing : ℝ := Real.sqrt 3 / 2
|
| 25 |
-
|
| 26 |
-
/-- The fixed Euclidean embedding in the unit triangular tiling. -/
|
| 27 |
-
noncomputable def centerPosition (v : Center) : ℝ × ℝ :=
|
| 28 |
-
if v.2.2 then
|
| 29 |
-
((v.1 : ℝ) + (v.2.1 : ℝ) / 2 + 1 / 2,
|
| 30 |
-
rowSpacing * ((v.2.1 : ℝ) + 1 / 3))
|
| 31 |
-
else
|
| 32 |
-
((v.1 : ℝ) + (v.2.1 : ℝ) / 2 + 1,
|
| 33 |
-
rowSpacing * ((v.2.1 : ℝ) + 2 / 3))
|
| 34 |
-
|
| 35 |
-
/-- A midpoint port, oriented into the triangle domain. -/
|
| 36 |
-
structure Port (D : Set Center) where
|
| 37 |
-
inside : Center
|
| 38 |
-
outside : Center
|
| 39 |
-
adjacent : Adj inside outside
|
| 40 |
-
inside_mem : inside ∈ D
|
| 41 |
-
outside_not_mem : outside ∉ D
|
| 42 |
-
|
| 43 |
-
noncomputable def Port.position {D : Set Center} (p : Port D) : ℝ × ℝ :=
|
| 44 |
-
((centerPosition p.inside).1 / 2 + (centerPosition p.outside).1 / 2,
|
| 45 |
-
(centerPosition p.inside).2 / 2 + (centerPosition p.outside).2 / 2)
|
| 46 |
-
|
| 47 |
-
/-- A simple center trace, with no premature boundary exit. -/
|
| 48 |
-
def IsTrace (D : Set Center) (p : List Center) : Prop :=
|
| 49 |
-
p.Nodup ∧ p.IsChain Adj ∧ ∀ v ∈ p, v ∈ D
|
| 50 |
-
|
| 51 |
-
noncomputable def kappa : ℝ := (2 + Real.sqrt 2) ^ (-(1 : ℝ) / 2)
|
| 52 |
-
|
| 53 |
-
/-- Length counts centers; the port half-edges contribute no factors. -/
|
| 54 |
-
noncomputable def weight (p : List Center) : ℝ≥0∞ :=
|
| 55 |
-
ENNReal.ofReal (kappa ^ p.length)
|
| 56 |
-
|
| 57 |
-
/-- The source's strip and tilt-compatible terminal support. -/
|
| 58 |
-
def strip (h : ℕ) : Set Center := {v | 0 ≤ v.2.1 ∧ v.2.1 < (h : ℤ)}
|
| 59 |
-
def StrictBridge (h : ℕ) :=
|
| 60 |
-
{p : List Center // IsTrace (strip h) p ∧ p.head? = some (up 0 0) ∧
|
| 61 |
-
∃ i : ℤ, p.getLast? = some (down i ((h : ℤ) - 1))}
|
| 62 |
-
noncomputable def bridgeMass (h : ℕ) : ℝ≥0∞ :=
|
| 63 |
-
if h = 0 then 1 else ∑' p : StrictBridge h, weight p.val
|
| 64 |
-
|
| 65 |
-
/-- Necessary estimate c:finite(1), inputs.tex:13, on the actual path sum. -/
|
| 66 |
-
def FiniteBridgeMassEstimate : Prop :=
|
| 67 |
-
∃ c C : ℝ, 0 < c ∧ 0 < C ∧ ∀ h : ℕ,
|
| 68 |
-
ENNReal.ofReal (c * (1 + (h : ℝ)) ^ (-(1 : ℝ) / 4)) ≤ bridgeMass h ∧
|
| 69 |
-
bridgeMass h ≤ ENNReal.ofReal (C * (1 + (h : ℝ)) ^ (-(1 : ℝ) / 4))
|
| 70 |
-
|
| 71 |
-
/-- Trusted reference hole only; missing necessary main obligation. -/
|
| 72 |
-
theorem finiteBridgeMassEstimate : FiniteBridgeMassEstimate := by
|
| 73 |
-
sorry
|
| 74 |
-
|
| 75 |
-
end CriticalHoneycomb
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
end OAI
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
namespace CriticalHoneycomb
|
| 6 |
+
open scoped ENNReal
|
| 7 |
+
|
| 8 |
+
abbrev Center := ℤ × ℤ × Bool
|
| 9 |
+
|
| 10 |
+
def up (i j : ℤ) : Center := (i, j, true)
|
| 11 |
+
def down (i j : ℤ) : Center := (i, j, false)
|
| 12 |
+
|
| 13 |
+
/-- Adjacency across a full triangular edge. -/
|
| 14 |
+
def Adj (v w : Center) : Prop :=
|
| 15 |
+
if v.2.2 then
|
| 16 |
+
w.2.2 = false ∧ ((w.1 = v.1 ∧ w.2.1 = v.2.1) ∨
|
| 17 |
+
(w.1 = v.1 ∧ w.2.1 = v.2.1 - 1) ∨
|
| 18 |
+
(w.1 = v.1 - 1 ∧ w.2.1 = v.2.1))
|
| 19 |
+
else
|
| 20 |
+
w.2.2 = true ∧ ((w.1 = v.1 ∧ w.2.1 = v.2.1) ∨
|
| 21 |
+
(w.1 = v.1 ∧ w.2.1 = v.2.1 + 1) ∨
|
| 22 |
+
(w.1 = v.1 + 1 ∧ w.2.1 = v.2.1))
|
| 23 |
+
|
| 24 |
+
noncomputable def rowSpacing : ℝ := Real.sqrt 3 / 2
|
| 25 |
+
|
| 26 |
+
/-- The fixed Euclidean embedding in the unit triangular tiling. -/
|
| 27 |
+
noncomputable def centerPosition (v : Center) : ℝ × ℝ :=
|
| 28 |
+
if v.2.2 then
|
| 29 |
+
((v.1 : ℝ) + (v.2.1 : ℝ) / 2 + 1 / 2,
|
| 30 |
+
rowSpacing * ((v.2.1 : ℝ) + 1 / 3))
|
| 31 |
+
else
|
| 32 |
+
((v.1 : ℝ) + (v.2.1 : ℝ) / 2 + 1,
|
| 33 |
+
rowSpacing * ((v.2.1 : ℝ) + 2 / 3))
|
| 34 |
+
|
| 35 |
+
/-- A midpoint port, oriented into the triangle domain. -/
|
| 36 |
+
structure Port (D : Set Center) where
|
| 37 |
+
inside : Center
|
| 38 |
+
outside : Center
|
| 39 |
+
adjacent : Adj inside outside
|
| 40 |
+
inside_mem : inside ∈ D
|
| 41 |
+
outside_not_mem : outside ∉ D
|
| 42 |
+
|
| 43 |
+
noncomputable def Port.position {D : Set Center} (p : Port D) : ℝ × ℝ :=
|
| 44 |
+
((centerPosition p.inside).1 / 2 + (centerPosition p.outside).1 / 2,
|
| 45 |
+
(centerPosition p.inside).2 / 2 + (centerPosition p.outside).2 / 2)
|
| 46 |
+
|
| 47 |
+
/-- A simple center trace, with no premature boundary exit. -/
|
| 48 |
+
def IsTrace (D : Set Center) (p : List Center) : Prop :=
|
| 49 |
+
p.Nodup ∧ p.IsChain Adj ∧ ∀ v ∈ p, v ∈ D
|
| 50 |
+
|
| 51 |
+
noncomputable def kappa : ℝ := (2 + Real.sqrt 2) ^ (-(1 : ℝ) / 2)
|
| 52 |
+
|
| 53 |
+
/-- Length counts centers; the port half-edges contribute no factors. -/
|
| 54 |
+
noncomputable def weight (p : List Center) : ℝ≥0∞ :=
|
| 55 |
+
ENNReal.ofReal (kappa ^ p.length)
|
| 56 |
+
|
| 57 |
+
/-- The source's strip and tilt-compatible terminal support. -/
|
| 58 |
+
def strip (h : ℕ) : Set Center := {v | 0 ≤ v.2.1 ∧ v.2.1 < (h : ℤ)}
|
| 59 |
+
def StrictBridge (h : ℕ) :=
|
| 60 |
+
{p : List Center // IsTrace (strip h) p ∧ p.head? = some (up 0 0) ∧
|
| 61 |
+
∃ i : ℤ, p.getLast? = some (down i ((h : ℤ) - 1))}
|
| 62 |
+
noncomputable def bridgeMass (h : ℕ) : ℝ≥0∞ :=
|
| 63 |
+
if h = 0 then 1 else ∑' p : StrictBridge h, weight p.val
|
| 64 |
+
|
| 65 |
+
/-- Necessary estimate c:finite(1), inputs.tex:13, on the actual path sum. -/
|
| 66 |
+
def FiniteBridgeMassEstimate : Prop :=
|
| 67 |
+
∃ c C : ℝ, 0 < c ∧ 0 < C ∧ ∀ h : ℕ,
|
| 68 |
+
ENNReal.ofReal (c * (1 + (h : ℝ)) ^ (-(1 : ℝ) / 4)) ≤ bridgeMass h ∧
|
| 69 |
+
bridgeMass h ≤ ENNReal.ofReal (C * (1 + (h : ℝ)) ^ (-(1 : ℝ) / 4))
|
| 70 |
+
|
| 71 |
+
/-- Trusted reference hole only; missing necessary main obligation. -/
|
| 72 |
+
theorem finiteBridgeMassEstimate : FiniteBridgeMassEstimate := by
|
| 73 |
+
sorry
|
| 74 |
+
|
| 75 |
+
end CriticalHoneycomb
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
end OAI
|
lean/ComparatorChallenges/LogspaceEquality.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
| 1 |
-
{
|
| 2 |
-
"challenge_module": "ComparatorChallenges.LogspaceEquality",
|
| 3 |
-
"solution_module": "OAI.Computability.Logspace.Equality",
|
| 4 |
-
"theorem_names": [
|
| 5 |
-
"OAI.ExactDerandomization.exact_logarithmic_space_derandomization"
|
| 6 |
-
],
|
| 7 |
-
"definition_names": [
|
| 8 |
-
"OAI.ExactDerandomization.Word",
|
| 9 |
-
"OAI.ExactDerandomization.Language",
|
| 10 |
-
"OAI.ExactDerandomization.CoinTape",
|
| 11 |
-
"OAI.ExactDerandomization.Direction.move",
|
| 12 |
-
"OAI.ExactDerandomization.Direction.moveInput",
|
| 13 |
-
"OAI.ExactDerandomization.readInput",
|
| 14 |
-
"OAI.ExactDerandomization.Machine.initial",
|
| 15 |
-
"OAI.ExactDerandomization.Machine.step",
|
| 16 |
-
"OAI.ExactDerandomization.Machine.run",
|
| 17 |
-
"OAI.ExactDerandomization.Machine.spaceThrough",
|
| 18 |
-
"OAI.ExactDerandomization.Machine.LogSpace",
|
| 19 |
-
"OAI.ExactDerandomization.Machine.Deterministic",
|
| 20 |
-
"OAI.ExactDerandomization.Machine.HaltsBy",
|
| 21 |
-
"OAI.ExactDerandomization.Machine.Decides",
|
| 22 |
-
"OAI.ExactDerandomization.Machine.extendCoins",
|
| 23 |
-
"OAI.ExactDerandomization.Machine.acceptanceProbability",
|
| 24 |
-
"OAI.ExactDerandomization.polynomialClock",
|
| 25 |
-
"OAI.ExactDerandomization.L",
|
| 26 |
-
"OAI.ExactDerandomization.RL",
|
| 27 |
-
"OAI.ExactDerandomization.BPL"
|
| 28 |
-
],
|
| 29 |
-
"permitted_axioms": [
|
| 30 |
-
"propext",
|
| 31 |
-
"Quot.sound",
|
| 32 |
-
"Classical.choice"
|
| 33 |
-
],
|
| 34 |
-
"enable_nanoda": false
|
| 35 |
-
}
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"challenge_module": "ComparatorChallenges.LogspaceEquality",
|
| 3 |
+
"solution_module": "OAI.Computability.Logspace.Equality",
|
| 4 |
+
"theorem_names": [
|
| 5 |
+
"OAI.ExactDerandomization.exact_logarithmic_space_derandomization"
|
| 6 |
+
],
|
| 7 |
+
"definition_names": [
|
| 8 |
+
"OAI.ExactDerandomization.Word",
|
| 9 |
+
"OAI.ExactDerandomization.Language",
|
| 10 |
+
"OAI.ExactDerandomization.CoinTape",
|
| 11 |
+
"OAI.ExactDerandomization.Direction.move",
|
| 12 |
+
"OAI.ExactDerandomization.Direction.moveInput",
|
| 13 |
+
"OAI.ExactDerandomization.readInput",
|
| 14 |
+
"OAI.ExactDerandomization.Machine.initial",
|
| 15 |
+
"OAI.ExactDerandomization.Machine.step",
|
| 16 |
+
"OAI.ExactDerandomization.Machine.run",
|
| 17 |
+
"OAI.ExactDerandomization.Machine.spaceThrough",
|
| 18 |
+
"OAI.ExactDerandomization.Machine.LogSpace",
|
| 19 |
+
"OAI.ExactDerandomization.Machine.Deterministic",
|
| 20 |
+
"OAI.ExactDerandomization.Machine.HaltsBy",
|
| 21 |
+
"OAI.ExactDerandomization.Machine.Decides",
|
| 22 |
+
"OAI.ExactDerandomization.Machine.extendCoins",
|
| 23 |
+
"OAI.ExactDerandomization.Machine.acceptanceProbability",
|
| 24 |
+
"OAI.ExactDerandomization.polynomialClock",
|
| 25 |
+
"OAI.ExactDerandomization.L",
|
| 26 |
+
"OAI.ExactDerandomization.RL",
|
| 27 |
+
"OAI.ExactDerandomization.BPL"
|
| 28 |
+
],
|
| 29 |
+
"permitted_axioms": [
|
| 30 |
+
"propext",
|
| 31 |
+
"Quot.sound",
|
| 32 |
+
"Classical.choice"
|
| 33 |
+
],
|
| 34 |
+
"enable_nanoda": false
|
| 35 |
+
}
|
lean/ComparatorChallenges/LogspaceEquality.lean
CHANGED
|
@@ -1,142 +1,142 @@
|
|
| 1 |
-
import Mathlib
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! Exact logarithmic-space derandomization for finite transition-table machines. -/
|
| 6 |
-
|
| 7 |
-
namespace ExactDerandomization
|
| 8 |
-
|
| 9 |
-
abbrev Word := List Bool
|
| 10 |
-
abbrev Language := Set Word
|
| 11 |
-
abbrev CoinTape := ℕ → Bool
|
| 12 |
-
|
| 13 |
-
inductive Direction where
|
| 14 |
-
| left | stay | right
|
| 15 |
-
deriving DecidableEq
|
| 16 |
-
|
| 17 |
-
inductive InputSymbol where
|
| 18 |
-
| leftMarker | bit (b : Bool) | rightMarker
|
| 19 |
-
deriving DecidableEq
|
| 20 |
-
|
| 21 |
-
def Direction.move (d : Direction) (z : ℤ) : ℤ :=
|
| 22 |
-
match d with
|
| 23 |
-
| .left => z - 1
|
| 24 |
-
| .stay => z
|
| 25 |
-
| .right => z + 1
|
| 26 |
-
|
| 27 |
-
def Direction.moveInput (d : Direction) {n : ℕ} (i : Fin (n + 2)) : Fin (n + 2) :=
|
| 28 |
-
match d with
|
| 29 |
-
| .left => ⟨i.val - 1, lt_of_le_of_lt (Nat.sub_le _ _) i.isLt⟩
|
| 30 |
-
| .stay => i
|
| 31 |
-
| .right => ⟨min (i.val + 1) (n + 1), by omega⟩
|
| 32 |
-
|
| 33 |
-
def readInput (x : Word) (i : Fin (x.length + 2)) : InputSymbol :=
|
| 34 |
-
if i.val = 0 then .leftMarker else
|
| 35 |
-
match x[i.val - 1]? with
|
| 36 |
-
| some b => .bit b
|
| 37 |
-
| none => .rightMarker
|
| 38 |
-
|
| 39 |
-
structure Action (q w h : ℕ) where
|
| 40 |
-
nextState : Fin (q + 1)
|
| 41 |
-
write : Fin w → Bool
|
| 42 |
-
workMove : Fin w → Direction
|
| 43 |
-
inputMove : Fin h → Direction
|
| 44 |
-
|
| 45 |
-
structure Machine (q w h : ℕ) where
|
| 46 |
-
initialState : Fin (q + 1)
|
| 47 |
-
output : Fin (q + 1) → Option Bool
|
| 48 |
-
transition : Fin (q + 1) → (Fin h → InputSymbol) → (Fin w → Bool) → Bool →
|
| 49 |
-
Action q w h
|
| 50 |
-
|
| 51 |
-
structure Configuration (q w h n : ℕ) where
|
| 52 |
-
state : Fin (q + 1)
|
| 53 |
-
inputPos : Fin h → Fin (n + 2)
|
| 54 |
-
workPos : Fin w → ℤ
|
| 55 |
-
work : Fin w → ℤ → Bool
|
| 56 |
-
|
| 57 |
-
namespace Machine
|
| 58 |
-
|
| 59 |
-
variable {q w h : ℕ}
|
| 60 |
-
|
| 61 |
-
def initial (M : Machine q w h) (n : ℕ) : Configuration q w h n where
|
| 62 |
-
state := M.initialState
|
| 63 |
-
inputPos := fun _ => ⟨0, by omega⟩
|
| 64 |
-
workPos := fun _ => 0
|
| 65 |
-
work := fun _ _ => false
|
| 66 |
-
|
| 67 |
-
def step (M : Machine q w h) (x : Word) (b : Bool)
|
| 68 |
-
(c : Configuration q w h x.length) : Configuration q w h x.length :=
|
| 69 |
-
match M.output c.state with
|
| 70 |
-
| some _ => c
|
| 71 |
-
| none =>
|
| 72 |
-
let a := M.transition c.state (fun j => readInput x (c.inputPos j))
|
| 73 |
-
(fun k => c.work k (c.workPos k)) b
|
| 74 |
-
{ state := a.nextState
|
| 75 |
-
inputPos := fun j => (a.inputMove j).moveInput (c.inputPos j)
|
| 76 |
-
workPos := fun k => (a.workMove k).move (c.workPos k)
|
| 77 |
-
work := fun k => Function.update (c.work k) (c.workPos k) (a.write k) }
|
| 78 |
-
|
| 79 |
-
def run (M : Machine q w h) (x : Word) (coins : CoinTape) :
|
| 80 |
-
ℕ → Configuration q w h x.length
|
| 81 |
-
| 0 => M.initial x.length
|
| 82 |
-
| t + 1 => M.step x (coins t) (M.run x coins t)
|
| 83 |
-
|
| 84 |
-
def spaceThrough (M : Machine q w h) (x : Word) (coins : CoinTape) (t : ℕ) : ℕ :=
|
| 85 |
-
∑ k : Fin w, ((Finset.range (t + 1)).image
|
| 86 |
-
(fun s => (M.run x coins s).workPos k)).card
|
| 87 |
-
|
| 88 |
-
def LogSpace (M : Machine q w h) : Prop :=
|
| 89 |
-
∃ c : ℕ, 0 < c ∧ ∀ (x : Word) (coins : CoinTape) (t : ℕ),
|
| 90 |
-
M.spaceThrough x coins t ≤ c * Nat.clog 2 (x.length + 2)
|
| 91 |
-
|
| 92 |
-
def Deterministic (M : Machine q w h) : Prop :=
|
| 93 |
-
∀ s i v, M.transition s i v false = M.transition s i v true
|
| 94 |
-
|
| 95 |
-
def HaltsBy (M : Machine q w h) (x : Word) (t : ℕ) : Prop :=
|
| 96 |
-
∀ coins : CoinTape, ∃ b : Bool, M.output (M.run x coins t).state = some b
|
| 97 |
-
|
| 98 |
-
def Decides (M : Machine q w h) (A : Language) : Prop :=
|
| 99 |
-
∀ x : Word, ∃ (t : ℕ) (b : Bool),
|
| 100 |
-
(b = true ↔ x ∈ A) ∧ ∀ coins : CoinTape,
|
| 101 |
-
M.output (M.run x coins t).state = some b
|
| 102 |
-
|
| 103 |
-
def extendCoins {t : ℕ} (bits : Fin t → Bool) : CoinTape :=
|
| 104 |
-
fun s => if hs : s < t then bits ⟨s, hs⟩ else false
|
| 105 |
-
|
| 106 |
-
def acceptanceProbability (M : Machine q w h) (x : Word) (t : ℕ) : ℚ :=
|
| 107 |
-
((Finset.univ.filter (fun bits : Fin t → Bool =>
|
| 108 |
-
M.output (M.run x (extendCoins bits) t).state = some true)).card : ℚ) /
|
| 109 |
-
(2 : ℚ) ^ t
|
| 110 |
-
|
| 111 |
-
end Machine
|
| 112 |
-
|
| 113 |
-
def polynomialClock (c k n : ℕ) : ℕ := c * (n + 2) ^ k
|
| 114 |
-
|
| 115 |
-
def L : Set Language :=
|
| 116 |
-
{A | ∃ (q w h : ℕ) (M : Machine q w h),
|
| 117 |
-
M.Deterministic ∧ M.LogSpace ∧ M.Decides A}
|
| 118 |
-
|
| 119 |
-
def RL : Set Language :=
|
| 120 |
-
{A | ∃ (q w h : ℕ) (M : Machine q w h),
|
| 121 |
-
M.LogSpace ∧ ∃ (c k : ℕ), 0 < c ∧ ∀ x : Word,
|
| 122 |
-
M.HaltsBy x (polynomialClock c k x.length) ∧
|
| 123 |
-
(x ∈ A → (1 / 2 : ℚ) ≤ M.acceptanceProbability x
|
| 124 |
-
(polynomialClock c k x.length)) ∧
|
| 125 |
-
(x ∉ A → M.acceptanceProbability x (polynomialClock c k x.length) = 0)}
|
| 126 |
-
|
| 127 |
-
def BPL : Set Language :=
|
| 128 |
-
{A | ∃ (q w h : ℕ) (M : Machine q w h),
|
| 129 |
-
M.LogSpace ∧ ∃ (c k : ℕ), 0 < c ∧ ∀ x : Word,
|
| 130 |
-
M.HaltsBy x (polynomialClock c k x.length) ∧
|
| 131 |
-
(x ∈ A → (2 / 3 : ℚ) ≤ M.acceptanceProbability x
|
| 132 |
-
(polynomialClock c k x.length)) ∧
|
| 133 |
-
(x ∉ A → M.acceptanceProbability x (polynomialClock c k x.length) ≤ (1 / 3 : ℚ))}
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
theorem exact_logarithmic_space_derandomization :
|
| 137 |
-
L = RL ∧ RL = BPL := by
|
| 138 |
-
sorry
|
| 139 |
-
|
| 140 |
-
end ExactDerandomization
|
| 141 |
-
|
| 142 |
-
end OAI
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! Exact logarithmic-space derandomization for finite transition-table machines. -/
|
| 6 |
+
|
| 7 |
+
namespace ExactDerandomization
|
| 8 |
+
|
| 9 |
+
abbrev Word := List Bool
|
| 10 |
+
abbrev Language := Set Word
|
| 11 |
+
abbrev CoinTape := ℕ → Bool
|
| 12 |
+
|
| 13 |
+
inductive Direction where
|
| 14 |
+
| left | stay | right
|
| 15 |
+
deriving DecidableEq
|
| 16 |
+
|
| 17 |
+
inductive InputSymbol where
|
| 18 |
+
| leftMarker | bit (b : Bool) | rightMarker
|
| 19 |
+
deriving DecidableEq
|
| 20 |
+
|
| 21 |
+
def Direction.move (d : Direction) (z : ℤ) : ℤ :=
|
| 22 |
+
match d with
|
| 23 |
+
| .left => z - 1
|
| 24 |
+
| .stay => z
|
| 25 |
+
| .right => z + 1
|
| 26 |
+
|
| 27 |
+
def Direction.moveInput (d : Direction) {n : ℕ} (i : Fin (n + 2)) : Fin (n + 2) :=
|
| 28 |
+
match d with
|
| 29 |
+
| .left => ⟨i.val - 1, lt_of_le_of_lt (Nat.sub_le _ _) i.isLt⟩
|
| 30 |
+
| .stay => i
|
| 31 |
+
| .right => ⟨min (i.val + 1) (n + 1), by omega⟩
|
| 32 |
+
|
| 33 |
+
def readInput (x : Word) (i : Fin (x.length + 2)) : InputSymbol :=
|
| 34 |
+
if i.val = 0 then .leftMarker else
|
| 35 |
+
match x[i.val - 1]? with
|
| 36 |
+
| some b => .bit b
|
| 37 |
+
| none => .rightMarker
|
| 38 |
+
|
| 39 |
+
structure Action (q w h : ℕ) where
|
| 40 |
+
nextState : Fin (q + 1)
|
| 41 |
+
write : Fin w → Bool
|
| 42 |
+
workMove : Fin w → Direction
|
| 43 |
+
inputMove : Fin h → Direction
|
| 44 |
+
|
| 45 |
+
structure Machine (q w h : ℕ) where
|
| 46 |
+
initialState : Fin (q + 1)
|
| 47 |
+
output : Fin (q + 1) → Option Bool
|
| 48 |
+
transition : Fin (q + 1) → (Fin h → InputSymbol) → (Fin w → Bool) → Bool →
|
| 49 |
+
Action q w h
|
| 50 |
+
|
| 51 |
+
structure Configuration (q w h n : ℕ) where
|
| 52 |
+
state : Fin (q + 1)
|
| 53 |
+
inputPos : Fin h → Fin (n + 2)
|
| 54 |
+
workPos : Fin w → ℤ
|
| 55 |
+
work : Fin w → ℤ → Bool
|
| 56 |
+
|
| 57 |
+
namespace Machine
|
| 58 |
+
|
| 59 |
+
variable {q w h : ℕ}
|
| 60 |
+
|
| 61 |
+
def initial (M : Machine q w h) (n : ℕ) : Configuration q w h n where
|
| 62 |
+
state := M.initialState
|
| 63 |
+
inputPos := fun _ => ⟨0, by omega⟩
|
| 64 |
+
workPos := fun _ => 0
|
| 65 |
+
work := fun _ _ => false
|
| 66 |
+
|
| 67 |
+
def step (M : Machine q w h) (x : Word) (b : Bool)
|
| 68 |
+
(c : Configuration q w h x.length) : Configuration q w h x.length :=
|
| 69 |
+
match M.output c.state with
|
| 70 |
+
| some _ => c
|
| 71 |
+
| none =>
|
| 72 |
+
let a := M.transition c.state (fun j => readInput x (c.inputPos j))
|
| 73 |
+
(fun k => c.work k (c.workPos k)) b
|
| 74 |
+
{ state := a.nextState
|
| 75 |
+
inputPos := fun j => (a.inputMove j).moveInput (c.inputPos j)
|
| 76 |
+
workPos := fun k => (a.workMove k).move (c.workPos k)
|
| 77 |
+
work := fun k => Function.update (c.work k) (c.workPos k) (a.write k) }
|
| 78 |
+
|
| 79 |
+
def run (M : Machine q w h) (x : Word) (coins : CoinTape) :
|
| 80 |
+
ℕ → Configuration q w h x.length
|
| 81 |
+
| 0 => M.initial x.length
|
| 82 |
+
| t + 1 => M.step x (coins t) (M.run x coins t)
|
| 83 |
+
|
| 84 |
+
def spaceThrough (M : Machine q w h) (x : Word) (coins : CoinTape) (t : ℕ) : ℕ :=
|
| 85 |
+
∑ k : Fin w, ((Finset.range (t + 1)).image
|
| 86 |
+
(fun s => (M.run x coins s).workPos k)).card
|
| 87 |
+
|
| 88 |
+
def LogSpace (M : Machine q w h) : Prop :=
|
| 89 |
+
∃ c : ℕ, 0 < c ∧ ∀ (x : Word) (coins : CoinTape) (t : ℕ),
|
| 90 |
+
M.spaceThrough x coins t ≤ c * Nat.clog 2 (x.length + 2)
|
| 91 |
+
|
| 92 |
+
def Deterministic (M : Machine q w h) : Prop :=
|
| 93 |
+
∀ s i v, M.transition s i v false = M.transition s i v true
|
| 94 |
+
|
| 95 |
+
def HaltsBy (M : Machine q w h) (x : Word) (t : ℕ) : Prop :=
|
| 96 |
+
∀ coins : CoinTape, ∃ b : Bool, M.output (M.run x coins t).state = some b
|
| 97 |
+
|
| 98 |
+
def Decides (M : Machine q w h) (A : Language) : Prop :=
|
| 99 |
+
∀ x : Word, ∃ (t : ℕ) (b : Bool),
|
| 100 |
+
(b = true ↔ x ∈ A) ∧ ∀ coins : CoinTape,
|
| 101 |
+
M.output (M.run x coins t).state = some b
|
| 102 |
+
|
| 103 |
+
def extendCoins {t : ℕ} (bits : Fin t → Bool) : CoinTape :=
|
| 104 |
+
fun s => if hs : s < t then bits ⟨s, hs⟩ else false
|
| 105 |
+
|
| 106 |
+
def acceptanceProbability (M : Machine q w h) (x : Word) (t : ℕ) : ℚ :=
|
| 107 |
+
((Finset.univ.filter (fun bits : Fin t → Bool =>
|
| 108 |
+
M.output (M.run x (extendCoins bits) t).state = some true)).card : ℚ) /
|
| 109 |
+
(2 : ℚ) ^ t
|
| 110 |
+
|
| 111 |
+
end Machine
|
| 112 |
+
|
| 113 |
+
def polynomialClock (c k n : ℕ) : ℕ := c * (n + 2) ^ k
|
| 114 |
+
|
| 115 |
+
def L : Set Language :=
|
| 116 |
+
{A | ∃ (q w h : ℕ) (M : Machine q w h),
|
| 117 |
+
M.Deterministic ∧ M.LogSpace ∧ M.Decides A}
|
| 118 |
+
|
| 119 |
+
def RL : Set Language :=
|
| 120 |
+
{A | ∃ (q w h : ℕ) (M : Machine q w h),
|
| 121 |
+
M.LogSpace ∧ ∃ (c k : ℕ), 0 < c ∧ ∀ x : Word,
|
| 122 |
+
M.HaltsBy x (polynomialClock c k x.length) ∧
|
| 123 |
+
(x ∈ A → (1 / 2 : ℚ) ≤ M.acceptanceProbability x
|
| 124 |
+
(polynomialClock c k x.length)) ∧
|
| 125 |
+
(x ∉ A → M.acceptanceProbability x (polynomialClock c k x.length) = 0)}
|
| 126 |
+
|
| 127 |
+
def BPL : Set Language :=
|
| 128 |
+
{A | ∃ (q w h : ℕ) (M : Machine q w h),
|
| 129 |
+
M.LogSpace ∧ ∃ (c k : ℕ), 0 < c ∧ ∀ x : Word,
|
| 130 |
+
M.HaltsBy x (polynomialClock c k x.length) ∧
|
| 131 |
+
(x ∈ A → (2 / 3 : ℚ) ≤ M.acceptanceProbability x
|
| 132 |
+
(polynomialClock c k x.length)) ∧
|
| 133 |
+
(x ∉ A → M.acceptanceProbability x (polynomialClock c k x.length) ≤ (1 / 3 : ℚ))}
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
theorem exact_logarithmic_space_derandomization :
|
| 137 |
+
L = RL ∧ RL = BPL := by
|
| 138 |
+
sorry
|
| 139 |
+
|
| 140 |
+
end ExactDerandomization
|
| 141 |
+
|
| 142 |
+
end OAI
|
lean/ComparatorChallenges/OneTapeSpace.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
| 1 |
-
{
|
| 2 |
-
"challenge_module": "ComparatorChallenges.OneTapeSpace",
|
| 3 |
-
"solution_module": "OAI.Computability.SpaceSimulation.Main",
|
| 4 |
-
"theorem_names": [
|
| 5 |
-
"OAI.Fifths.Single.capped",
|
| 6 |
-
"OAI.Fifths.Single.unknown"
|
| 7 |
-
],
|
| 8 |
-
"definition_names": [],
|
| 9 |
-
"permitted_axioms": [
|
| 10 |
-
"propext",
|
| 11 |
-
"Classical.choice",
|
| 12 |
-
"Quot.sound"
|
| 13 |
-
],
|
| 14 |
-
"enable_nanoda": false
|
| 15 |
-
}
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"challenge_module": "ComparatorChallenges.OneTapeSpace",
|
| 3 |
+
"solution_module": "OAI.Computability.SpaceSimulation.Main",
|
| 4 |
+
"theorem_names": [
|
| 5 |
+
"OAI.Fifths.Single.capped",
|
| 6 |
+
"OAI.Fifths.Single.unknown"
|
| 7 |
+
],
|
| 8 |
+
"definition_names": [],
|
| 9 |
+
"permitted_axioms": [
|
| 10 |
+
"propext",
|
| 11 |
+
"Classical.choice",
|
| 12 |
+
"Quot.sound"
|
| 13 |
+
],
|
| 14 |
+
"enable_nanoda": false
|
| 15 |
+
}
|
lean/ComparatorChallenges/OneTapeSpace.lean
CHANGED
|
@@ -1,275 +1,275 @@
|
|
| 1 |
-
import Mathlib
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! Finite-machine statements of the capped and unknown-time one-writable-tape
|
| 6 |
-
simulation theorem. Work space counts the bits in every visited writable cell;
|
| 7 |
-
public endmarked input tapes are read-only. -/
|
| 8 |
-
|
| 9 |
-
namespace Fifths
|
| 10 |
-
|
| 11 |
-
inductive Dir
|
| 12 |
-
| L | N | R
|
| 13 |
-
deriving DecidableEq
|
| 14 |
-
|
| 15 |
-
instance : Fintype Dir := ⟨{.L, .N, .R}, by intro d; cases d <;> simp⟩
|
| 16 |
-
|
| 17 |
-
namespace Dir
|
| 18 |
-
@[simp] def delta : Dir → ℤ
|
| 19 |
-
| L => -1
|
| 20 |
-
| N => 0
|
| 21 |
-
| R => 1
|
| 22 |
-
end Dir
|
| 23 |
-
|
| 24 |
-
inductive Mark (A : Type)
|
| 25 |
-
| left
|
| 26 |
-
| sym (a : A)
|
| 27 |
-
| right
|
| 28 |
-
deriving DecidableEq, Fintype
|
| 29 |
-
|
| 30 |
-
namespace Mark
|
| 31 |
-
variable {A : Type}
|
| 32 |
-
def see (w : List A) : ℕ → Mark A
|
| 33 |
-
| 0 => left
|
| 34 |
-
| p+1 =>
|
| 35 |
-
match w[p]? with
|
| 36 |
-
| some a => sym a
|
| 37 |
-
| none => right
|
| 38 |
-
|
| 39 |
-
def walk (w : List A) (p : ℕ) : Dir → ℕ
|
| 40 |
-
| .N => p
|
| 41 |
-
| .L => p - 1
|
| 42 |
-
| .R => if w.length < p then p else p + 1
|
| 43 |
-
end Mark
|
| 44 |
-
|
| 45 |
-
inductive Runs {σ Y : Type} (f : σ → Y ⊕ σ) (P : σ → Prop) :
|
| 46 |
-
σ → σ → Y → Prop
|
| 47 |
-
| stop {s y} (ok : P s) (eqn : f s = Sum.inl y) : Runs f P s s y
|
| 48 |
-
| step {s s' t y} (ok : P s) (eqn : f s = Sum.inr s')
|
| 49 |
-
(tail : Runs f P s' t y) : Runs f P s t y
|
| 50 |
-
|
| 51 |
-
structure Inputs (X J : Type) where
|
| 52 |
-
publicWord : List X
|
| 53 |
-
arg : J → List Bool
|
| 54 |
-
|
| 55 |
-
structure Readers (J : Type) where
|
| 56 |
-
px : ℕ := 0
|
| 57 |
-
parg : J → ℕ := fun _ => 0
|
| 58 |
-
|
| 59 |
-
structure Reads (X J : Type) where
|
| 60 |
-
sx : Mark X
|
| 61 |
-
sarg : J → Mark Bool
|
| 62 |
-
|
| 63 |
-
structure Advances (J : Type) where
|
| 64 |
-
dx : Dir := .N
|
| 65 |
-
darg : J → Dir := fun _ => .N
|
| 66 |
-
|
| 67 |
-
namespace Readers
|
| 68 |
-
variable {X J : Type}
|
| 69 |
-
def home : Readers J := {}
|
| 70 |
-
def see (r : Readers J) (i : Inputs X J) : Reads X J :=
|
| 71 |
-
⟨Mark.see i.publicWord r.px, fun j => Mark.see (i.arg j) (r.parg j)⟩
|
| 72 |
-
def walk (r : Readers J) (i : Inputs X J) (a : Advances J) : Readers J :=
|
| 73 |
-
⟨Mark.walk i.publicWord r.px a.dx, fun j => Mark.walk (i.arg j) (r.parg j) (a.darg j)⟩
|
| 74 |
-
end Readers
|
| 75 |
-
|
| 76 |
-
structure Tape (A : Type) where
|
| 77 |
-
pos : ℤ
|
| 78 |
-
sym : ℤ → A
|
| 79 |
-
|
| 80 |
-
structure WriteMove (A : Type) where
|
| 81 |
-
sym : A
|
| 82 |
-
dir : Dir
|
| 83 |
-
|
| 84 |
-
namespace Tape
|
| 85 |
-
variable {A : Type}
|
| 86 |
-
def init (a : A) : Tape A := ⟨0, fun _ => a⟩
|
| 87 |
-
def see (w : Tape A) : A := w.sym w.pos
|
| 88 |
-
def perform (w : Tape A) (m : WriteMove A) : Tape A :=
|
| 89 |
-
⟨w.pos + m.dir.delta, Function.update w.sym w.pos m.sym⟩
|
| 90 |
-
end Tape
|
| 91 |
-
|
| 92 |
-
structure TAction (Q J K : Type) (W : K → Type) where
|
| 93 |
-
next : Q
|
| 94 |
-
advance : Advances J
|
| 95 |
-
moves : ∀ k : K, WriteMove (W k)
|
| 96 |
-
|
| 97 |
-
structure TM (X J Y : Type) where
|
| 98 |
-
Q : Type
|
| 99 |
-
[finiteQ : Finite Q]
|
| 100 |
-
K : Type
|
| 101 |
-
[tapes : Fintype K]
|
| 102 |
-
W : K → Type
|
| 103 |
-
[symbols : ∀ k, Fintype (W k)]
|
| 104 |
-
blank : ∀ k, W k
|
| 105 |
-
start : Q
|
| 106 |
-
table : Q → Reads X J → ((k : K) → W k) → Y ⊕ TAction Q J K W
|
| 107 |
-
|
| 108 |
-
attribute [instance] TM.finiteQ TM.tapes TM.symbols
|
| 109 |
-
|
| 110 |
-
namespace TM
|
| 111 |
-
variable {X J Y : Type} (M : TM X J Y)
|
| 112 |
-
|
| 113 |
-
structure Cfg where
|
| 114 |
-
state : M.Q
|
| 115 |
-
ro : Readers J
|
| 116 |
-
work : ∀ k, Tape (M.W k)
|
| 117 |
-
|
| 118 |
-
def initial : M.Cfg :=
|
| 119 |
-
⟨M.start, .home, fun k => .init (M.blank k)⟩
|
| 120 |
-
|
| 121 |
-
def step (i : Inputs X J) (s : M.Cfg) : Y ⊕ M.Cfg :=
|
| 122 |
-
match M.table s.state (s.ro.see i) (fun k => (s.work k).see) with
|
| 123 |
-
| Sum.inl y => .inl y
|
| 124 |
-
| Sum.inr a =>
|
| 125 |
-
.inr ⟨a.next, s.ro.walk i a.advance, fun k => (s.work k).perform (a.moves k)⟩
|
| 126 |
-
|
| 127 |
-
structure Window where
|
| 128 |
-
l : M.K → ℕ
|
| 129 |
-
h : M.K → ℕ
|
| 130 |
-
|
| 131 |
-
def width (k : M.K) : ℕ := max 1 (Fintype.card (M.W k) - 1).size
|
| 132 |
-
|
| 133 |
-
namespace Window
|
| 134 |
-
variable {M}
|
| 135 |
-
def ok (w : M.Window) (s : M.Cfg) : Prop :=
|
| 136 |
-
∀ k, -(w.l k : ℤ) ≤ (s.work k).pos ∧ (s.work k).pos ≤ (w.h k : ℤ)
|
| 137 |
-
open BigOperators
|
| 138 |
-
def bits (w : M.Window) : ℕ :=
|
| 139 |
-
∑ k, (w.l k + w.h k + 1) * M.width k
|
| 140 |
-
end Window
|
| 141 |
-
|
| 142 |
-
def Within (i : Inputs X J) (y : Y) (S : ℕ) : Prop :=
|
| 143 |
-
∃ w : M.Window, w.bits ≤ S ∧ ∃ t, Runs (M.step i) w.ok M.initial t y
|
| 144 |
-
end TM
|
| 145 |
-
|
| 146 |
-
end Fifths
|
| 147 |
-
|
| 148 |
-
namespace Fifths
|
| 149 |
-
|
| 150 |
-
structure SingleAct (Q A : Type) (r : ℕ) where
|
| 151 |
-
out : Q
|
| 152 |
-
write : WriteMove A
|
| 153 |
-
others : Fin r → Dir
|
| 154 |
-
|
| 155 |
-
structure Single (X : Type) where
|
| 156 |
-
Q : Type
|
| 157 |
-
[states : Fintype Q]
|
| 158 |
-
A : Type
|
| 159 |
-
[symbols : Fintype A]
|
| 160 |
-
beginState : Q
|
| 161 |
-
halted : Q → Bool
|
| 162 |
-
heads : ℕ
|
| 163 |
-
program : Q → A → (Fin heads → A) → SingleAct Q A heads
|
| 164 |
-
sensor : List X → Option (Fin heads) → ℤ → A
|
| 165 |
-
|
| 166 |
-
attribute [instance] Single.states Single.symbols
|
| 167 |
-
|
| 168 |
-
namespace Single
|
| 169 |
-
variable {X : Type} (M : Single X)
|
| 170 |
-
instance : Nonempty M.A := ⟨M.sensor [] none 0⟩
|
| 171 |
-
instance : Nonempty M.Q := ⟨M.beginState⟩
|
| 172 |
-
abbrev Tag := Option (Fin M.heads)
|
| 173 |
-
|
| 174 |
-
structure At where
|
| 175 |
-
state : M.Q
|
| 176 |
-
tape : Tape M.A
|
| 177 |
-
ro : Fin M.heads → ℤ
|
| 178 |
-
|
| 179 |
-
def move (q : M.Q) (s : M.A) (r : Fin M.heads → M.A) :
|
| 180 |
-
SingleAct M.Q M.A M.heads :=
|
| 181 |
-
if M.halted q then
|
| 182 |
-
⟨q,⟨s,.N⟩,fun _ => .N⟩
|
| 183 |
-
else M.program q s r
|
| 184 |
-
|
| 185 |
-
def initial (x : List X) : M.At :=
|
| 186 |
-
⟨M.beginState,⟨0,M.sensor x none⟩, fun _ => 0⟩
|
| 187 |
-
|
| 188 |
-
def next (x : List X) (s : M.At) : M.At :=
|
| 189 |
-
let t := M.move s.state s.tape.see (fun i => M.sensor x (some i) (s.ro i))
|
| 190 |
-
⟨t.out,s.tape.perform t.write,fun i => s.ro i + (t.others i).delta⟩
|
| 191 |
-
|
| 192 |
-
def atTime (M : Single X) (x : List X) : ℕ → M.At :=
|
| 193 |
-
Nat.rec (M.initial x) (fun _ s => M.next x s)
|
| 194 |
-
|
| 195 |
-
abbrev Outcome := M.Q × Bool
|
| 196 |
-
def finish (q : M.Q) : M.Outcome :=
|
| 197 |
-
(q, M.halted q)
|
| 198 |
-
def outcome (x : List X) (n : ℕ) : M.Outcome :=
|
| 199 |
-
M.finish (M.atTime x n).state
|
| 200 |
-
|
| 201 |
-
def Inside (t : ℕ) (q : ℤ) : Prop := -(t:ℤ) ≤ q ∧ q ≤ (t:ℤ)
|
| 202 |
-
end Single
|
| 203 |
-
|
| 204 |
-
end Fifths
|
| 205 |
-
|
| 206 |
-
namespace Fifths
|
| 207 |
-
|
| 208 |
-
namespace Entry
|
| 209 |
-
noncomputable def code {A : Type} [Fintype A] (a : A) : ℕ :=
|
| 210 |
-
(Fintype.equivFin A a).val
|
| 211 |
-
end Entry
|
| 212 |
-
|
| 213 |
-
def binaryIn {X J : Type} (pub : List X) (f : J → ℕ) : Inputs X J :=
|
| 214 |
-
⟨pub, fun j => (f j).bits⟩
|
| 215 |
-
|
| 216 |
-
def files {X : Type} (x : List X) : Inputs X Empty :=
|
| 217 |
-
⟨x, Empty.elim⟩
|
| 218 |
-
|
| 219 |
-
namespace Single
|
| 220 |
-
open Entry
|
| 221 |
-
variable {X : Type} (M : Single X)
|
| 222 |
-
|
| 223 |
-
inductive Arg
|
| 224 |
-
| cap | tag | minus | magnitude
|
| 225 |
-
deriving DecidableEq
|
| 226 |
-
|
| 227 |
-
instance : Fintype Arg :=
|
| 228 |
-
⟨{.cap, .tag, .minus, .magnitude}, by intro a; cases a <;> simp⟩
|
| 229 |
-
abbrev Sym := TM X Arg M.A
|
| 230 |
-
|
| 231 |
-
noncomputable def arg (T : ℕ) (h : M.Tag) (p : ℤ) : Arg → ℕ
|
| 232 |
-
| .cap => T
|
| 233 |
-
| .tag => code h
|
| 234 |
-
| .minus => (decide (p < 0)).toNat
|
| 235 |
-
| .magnitude => p.natAbs
|
| 236 |
-
end Single
|
| 237 |
-
|
| 238 |
-
namespace Cost
|
| 239 |
-
noncomputable def Log (T : ℕ) := Real.log (T+2 : ℝ) / Real.log 2
|
| 240 |
-
noncomputable def exponent := (2:ℝ)/5
|
| 241 |
-
end Cost
|
| 242 |
-
|
| 243 |
-
namespace Single
|
| 244 |
-
open Cost
|
| 245 |
-
variable {X : Type} (M : Single X)
|
| 246 |
-
def Access (A : M.Sym) (p q : ℝ) (x : List X) (T : ℕ) : Prop :=
|
| 247 |
-
∀ (h : M.Tag) (l : ℤ), Inside T l →
|
| 248 |
-
∃ s : ℕ, (s:ℝ) ≤ p * (Log T)^q ∧
|
| 249 |
-
A.Within (binaryIn x (M.arg T h l)) (M.sensor x h l) s
|
| 250 |
-
end Single
|
| 251 |
-
|
| 252 |
-
end Fifths
|
| 253 |
-
|
| 254 |
-
namespace Fifths.Single
|
| 255 |
-
open Entry Cost
|
| 256 |
-
variable {X : Type} (M : Single X)
|
| 257 |
-
|
| 258 |
-
theorem capped [Fintype X] (A : M.Sym) (p q : ℝ) (hp : 1 ≤ p) (_hq : 1 ≤ q) :
|
| 259 |
-
∃ (N : TM X Unit M.Outcome) (e : ℕ) (c : ℝ), 0 < c ∧
|
| 260 |
-
∀ (x : List X) (T : ℕ), 2 ≤ T → M.Access A p q x T →
|
| 261 |
-
∃ b : ℕ, N.Within (binaryIn x (fun _ => T)) (M.outcome x T) b ∧
|
| 262 |
-
(b:ℝ) ≤ c*(T:ℝ)^exponent*(Log T)^e := by
|
| 263 |
-
sorry
|
| 264 |
-
|
| 265 |
-
theorem unknown [Fintype X] (A : M.Sym) (p q : ℝ) (hp : 1 ≤ p) (_hq : 1 ≤ q) :
|
| 266 |
-
∃ (N : TM X Empty M.Outcome) (e : ℕ) (c : ℝ), 0 < c ∧
|
| 267 |
-
∀ (x : List X), (∀ T, 2 ≤ T → M.Access A p q x T) →
|
| 268 |
-
∀ (t : ℕ), (M.outcome x t).2 = true →
|
| 269 |
-
∃ b, N.Within (files x) (M.outcome x t) b ∧
|
| 270 |
-
(b:ℝ) ≤ c*((t:ℝ)+2)^exponent*(Log t)^e := by
|
| 271 |
-
sorry
|
| 272 |
-
|
| 273 |
-
end Fifths.Single
|
| 274 |
-
|
| 275 |
-
end OAI
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! Finite-machine statements of the capped and unknown-time one-writable-tape
|
| 6 |
+
simulation theorem. Work space counts the bits in every visited writable cell;
|
| 7 |
+
public endmarked input tapes are read-only. -/
|
| 8 |
+
|
| 9 |
+
namespace Fifths
|
| 10 |
+
|
| 11 |
+
inductive Dir
|
| 12 |
+
| L | N | R
|
| 13 |
+
deriving DecidableEq
|
| 14 |
+
|
| 15 |
+
instance : Fintype Dir := ⟨{.L, .N, .R}, by intro d; cases d <;> simp⟩
|
| 16 |
+
|
| 17 |
+
namespace Dir
|
| 18 |
+
@[simp] def delta : Dir → ℤ
|
| 19 |
+
| L => -1
|
| 20 |
+
| N => 0
|
| 21 |
+
| R => 1
|
| 22 |
+
end Dir
|
| 23 |
+
|
| 24 |
+
inductive Mark (A : Type)
|
| 25 |
+
| left
|
| 26 |
+
| sym (a : A)
|
| 27 |
+
| right
|
| 28 |
+
deriving DecidableEq, Fintype
|
| 29 |
+
|
| 30 |
+
namespace Mark
|
| 31 |
+
variable {A : Type}
|
| 32 |
+
def see (w : List A) : ℕ → Mark A
|
| 33 |
+
| 0 => left
|
| 34 |
+
| p+1 =>
|
| 35 |
+
match w[p]? with
|
| 36 |
+
| some a => sym a
|
| 37 |
+
| none => right
|
| 38 |
+
|
| 39 |
+
def walk (w : List A) (p : ℕ) : Dir → ℕ
|
| 40 |
+
| .N => p
|
| 41 |
+
| .L => p - 1
|
| 42 |
+
| .R => if w.length < p then p else p + 1
|
| 43 |
+
end Mark
|
| 44 |
+
|
| 45 |
+
inductive Runs {σ Y : Type} (f : σ → Y ⊕ σ) (P : σ → Prop) :
|
| 46 |
+
σ → σ → Y → Prop
|
| 47 |
+
| stop {s y} (ok : P s) (eqn : f s = Sum.inl y) : Runs f P s s y
|
| 48 |
+
| step {s s' t y} (ok : P s) (eqn : f s = Sum.inr s')
|
| 49 |
+
(tail : Runs f P s' t y) : Runs f P s t y
|
| 50 |
+
|
| 51 |
+
structure Inputs (X J : Type) where
|
| 52 |
+
publicWord : List X
|
| 53 |
+
arg : J → List Bool
|
| 54 |
+
|
| 55 |
+
structure Readers (J : Type) where
|
| 56 |
+
px : ℕ := 0
|
| 57 |
+
parg : J → ℕ := fun _ => 0
|
| 58 |
+
|
| 59 |
+
structure Reads (X J : Type) where
|
| 60 |
+
sx : Mark X
|
| 61 |
+
sarg : J → Mark Bool
|
| 62 |
+
|
| 63 |
+
structure Advances (J : Type) where
|
| 64 |
+
dx : Dir := .N
|
| 65 |
+
darg : J → Dir := fun _ => .N
|
| 66 |
+
|
| 67 |
+
namespace Readers
|
| 68 |
+
variable {X J : Type}
|
| 69 |
+
def home : Readers J := {}
|
| 70 |
+
def see (r : Readers J) (i : Inputs X J) : Reads X J :=
|
| 71 |
+
⟨Mark.see i.publicWord r.px, fun j => Mark.see (i.arg j) (r.parg j)⟩
|
| 72 |
+
def walk (r : Readers J) (i : Inputs X J) (a : Advances J) : Readers J :=
|
| 73 |
+
⟨Mark.walk i.publicWord r.px a.dx, fun j => Mark.walk (i.arg j) (r.parg j) (a.darg j)⟩
|
| 74 |
+
end Readers
|
| 75 |
+
|
| 76 |
+
structure Tape (A : Type) where
|
| 77 |
+
pos : ℤ
|
| 78 |
+
sym : ℤ → A
|
| 79 |
+
|
| 80 |
+
structure WriteMove (A : Type) where
|
| 81 |
+
sym : A
|
| 82 |
+
dir : Dir
|
| 83 |
+
|
| 84 |
+
namespace Tape
|
| 85 |
+
variable {A : Type}
|
| 86 |
+
def init (a : A) : Tape A := ⟨0, fun _ => a⟩
|
| 87 |
+
def see (w : Tape A) : A := w.sym w.pos
|
| 88 |
+
def perform (w : Tape A) (m : WriteMove A) : Tape A :=
|
| 89 |
+
⟨w.pos + m.dir.delta, Function.update w.sym w.pos m.sym⟩
|
| 90 |
+
end Tape
|
| 91 |
+
|
| 92 |
+
structure TAction (Q J K : Type) (W : K → Type) where
|
| 93 |
+
next : Q
|
| 94 |
+
advance : Advances J
|
| 95 |
+
moves : ∀ k : K, WriteMove (W k)
|
| 96 |
+
|
| 97 |
+
structure TM (X J Y : Type) where
|
| 98 |
+
Q : Type
|
| 99 |
+
[finiteQ : Finite Q]
|
| 100 |
+
K : Type
|
| 101 |
+
[tapes : Fintype K]
|
| 102 |
+
W : K → Type
|
| 103 |
+
[symbols : ∀ k, Fintype (W k)]
|
| 104 |
+
blank : ∀ k, W k
|
| 105 |
+
start : Q
|
| 106 |
+
table : Q → Reads X J → ((k : K) → W k) → Y ⊕ TAction Q J K W
|
| 107 |
+
|
| 108 |
+
attribute [instance] TM.finiteQ TM.tapes TM.symbols
|
| 109 |
+
|
| 110 |
+
namespace TM
|
| 111 |
+
variable {X J Y : Type} (M : TM X J Y)
|
| 112 |
+
|
| 113 |
+
structure Cfg where
|
| 114 |
+
state : M.Q
|
| 115 |
+
ro : Readers J
|
| 116 |
+
work : ∀ k, Tape (M.W k)
|
| 117 |
+
|
| 118 |
+
def initial : M.Cfg :=
|
| 119 |
+
⟨M.start, .home, fun k => .init (M.blank k)⟩
|
| 120 |
+
|
| 121 |
+
def step (i : Inputs X J) (s : M.Cfg) : Y ⊕ M.Cfg :=
|
| 122 |
+
match M.table s.state (s.ro.see i) (fun k => (s.work k).see) with
|
| 123 |
+
| Sum.inl y => .inl y
|
| 124 |
+
| Sum.inr a =>
|
| 125 |
+
.inr ⟨a.next, s.ro.walk i a.advance, fun k => (s.work k).perform (a.moves k)⟩
|
| 126 |
+
|
| 127 |
+
structure Window where
|
| 128 |
+
l : M.K → ℕ
|
| 129 |
+
h : M.K → ℕ
|
| 130 |
+
|
| 131 |
+
def width (k : M.K) : ℕ := max 1 (Fintype.card (M.W k) - 1).size
|
| 132 |
+
|
| 133 |
+
namespace Window
|
| 134 |
+
variable {M}
|
| 135 |
+
def ok (w : M.Window) (s : M.Cfg) : Prop :=
|
| 136 |
+
∀ k, -(w.l k : ℤ) ≤ (s.work k).pos ∧ (s.work k).pos ≤ (w.h k : ℤ)
|
| 137 |
+
open BigOperators
|
| 138 |
+
def bits (w : M.Window) : ℕ :=
|
| 139 |
+
∑ k, (w.l k + w.h k + 1) * M.width k
|
| 140 |
+
end Window
|
| 141 |
+
|
| 142 |
+
def Within (i : Inputs X J) (y : Y) (S : ℕ) : Prop :=
|
| 143 |
+
∃ w : M.Window, w.bits ≤ S ∧ ∃ t, Runs (M.step i) w.ok M.initial t y
|
| 144 |
+
end TM
|
| 145 |
+
|
| 146 |
+
end Fifths
|
| 147 |
+
|
| 148 |
+
namespace Fifths
|
| 149 |
+
|
| 150 |
+
structure SingleAct (Q A : Type) (r : ℕ) where
|
| 151 |
+
out : Q
|
| 152 |
+
write : WriteMove A
|
| 153 |
+
others : Fin r → Dir
|
| 154 |
+
|
| 155 |
+
structure Single (X : Type) where
|
| 156 |
+
Q : Type
|
| 157 |
+
[states : Fintype Q]
|
| 158 |
+
A : Type
|
| 159 |
+
[symbols : Fintype A]
|
| 160 |
+
beginState : Q
|
| 161 |
+
halted : Q → Bool
|
| 162 |
+
heads : ℕ
|
| 163 |
+
program : Q → A → (Fin heads → A) → SingleAct Q A heads
|
| 164 |
+
sensor : List X → Option (Fin heads) → ℤ → A
|
| 165 |
+
|
| 166 |
+
attribute [instance] Single.states Single.symbols
|
| 167 |
+
|
| 168 |
+
namespace Single
|
| 169 |
+
variable {X : Type} (M : Single X)
|
| 170 |
+
instance : Nonempty M.A := ⟨M.sensor [] none 0⟩
|
| 171 |
+
instance : Nonempty M.Q := ⟨M.beginState⟩
|
| 172 |
+
abbrev Tag := Option (Fin M.heads)
|
| 173 |
+
|
| 174 |
+
structure At where
|
| 175 |
+
state : M.Q
|
| 176 |
+
tape : Tape M.A
|
| 177 |
+
ro : Fin M.heads → ℤ
|
| 178 |
+
|
| 179 |
+
def move (q : M.Q) (s : M.A) (r : Fin M.heads → M.A) :
|
| 180 |
+
SingleAct M.Q M.A M.heads :=
|
| 181 |
+
if M.halted q then
|
| 182 |
+
⟨q,⟨s,.N⟩,fun _ => .N⟩
|
| 183 |
+
else M.program q s r
|
| 184 |
+
|
| 185 |
+
def initial (x : List X) : M.At :=
|
| 186 |
+
⟨M.beginState,⟨0,M.sensor x none⟩, fun _ => 0⟩
|
| 187 |
+
|
| 188 |
+
def next (x : List X) (s : M.At) : M.At :=
|
| 189 |
+
let t := M.move s.state s.tape.see (fun i => M.sensor x (some i) (s.ro i))
|
| 190 |
+
⟨t.out,s.tape.perform t.write,fun i => s.ro i + (t.others i).delta⟩
|
| 191 |
+
|
| 192 |
+
def atTime (M : Single X) (x : List X) : ℕ → M.At :=
|
| 193 |
+
Nat.rec (M.initial x) (fun _ s => M.next x s)
|
| 194 |
+
|
| 195 |
+
abbrev Outcome := M.Q × Bool
|
| 196 |
+
def finish (q : M.Q) : M.Outcome :=
|
| 197 |
+
(q, M.halted q)
|
| 198 |
+
def outcome (x : List X) (n : ℕ) : M.Outcome :=
|
| 199 |
+
M.finish (M.atTime x n).state
|
| 200 |
+
|
| 201 |
+
def Inside (t : ℕ) (q : ℤ) : Prop := -(t:ℤ) ≤ q ∧ q ≤ (t:ℤ)
|
| 202 |
+
end Single
|
| 203 |
+
|
| 204 |
+
end Fifths
|
| 205 |
+
|
| 206 |
+
namespace Fifths
|
| 207 |
+
|
| 208 |
+
namespace Entry
|
| 209 |
+
noncomputable def code {A : Type} [Fintype A] (a : A) : ℕ :=
|
| 210 |
+
(Fintype.equivFin A a).val
|
| 211 |
+
end Entry
|
| 212 |
+
|
| 213 |
+
def binaryIn {X J : Type} (pub : List X) (f : J → ℕ) : Inputs X J :=
|
| 214 |
+
⟨pub, fun j => (f j).bits⟩
|
| 215 |
+
|
| 216 |
+
def files {X : Type} (x : List X) : Inputs X Empty :=
|
| 217 |
+
⟨x, Empty.elim⟩
|
| 218 |
+
|
| 219 |
+
namespace Single
|
| 220 |
+
open Entry
|
| 221 |
+
variable {X : Type} (M : Single X)
|
| 222 |
+
|
| 223 |
+
inductive Arg
|
| 224 |
+
| cap | tag | minus | magnitude
|
| 225 |
+
deriving DecidableEq
|
| 226 |
+
|
| 227 |
+
instance : Fintype Arg :=
|
| 228 |
+
⟨{.cap, .tag, .minus, .magnitude}, by intro a; cases a <;> simp⟩
|
| 229 |
+
abbrev Sym := TM X Arg M.A
|
| 230 |
+
|
| 231 |
+
noncomputable def arg (T : ℕ) (h : M.Tag) (p : ℤ) : Arg → ℕ
|
| 232 |
+
| .cap => T
|
| 233 |
+
| .tag => code h
|
| 234 |
+
| .minus => (decide (p < 0)).toNat
|
| 235 |
+
| .magnitude => p.natAbs
|
| 236 |
+
end Single
|
| 237 |
+
|
| 238 |
+
namespace Cost
|
| 239 |
+
noncomputable def Log (T : ℕ) := Real.log (T+2 : ℝ) / Real.log 2
|
| 240 |
+
noncomputable def exponent := (2:ℝ)/5
|
| 241 |
+
end Cost
|
| 242 |
+
|
| 243 |
+
namespace Single
|
| 244 |
+
open Cost
|
| 245 |
+
variable {X : Type} (M : Single X)
|
| 246 |
+
def Access (A : M.Sym) (p q : ℝ) (x : List X) (T : ℕ) : Prop :=
|
| 247 |
+
∀ (h : M.Tag) (l : ℤ), Inside T l →
|
| 248 |
+
∃ s : ℕ, (s:ℝ) ≤ p * (Log T)^q ∧
|
| 249 |
+
A.Within (binaryIn x (M.arg T h l)) (M.sensor x h l) s
|
| 250 |
+
end Single
|
| 251 |
+
|
| 252 |
+
end Fifths
|
| 253 |
+
|
| 254 |
+
namespace Fifths.Single
|
| 255 |
+
open Entry Cost
|
| 256 |
+
variable {X : Type} (M : Single X)
|
| 257 |
+
|
| 258 |
+
theorem capped [Fintype X] (A : M.Sym) (p q : ℝ) (hp : 1 ≤ p) (_hq : 1 ≤ q) :
|
| 259 |
+
∃ (N : TM X Unit M.Outcome) (e : ℕ) (c : ℝ), 0 < c ∧
|
| 260 |
+
∀ (x : List X) (T : ℕ), 2 ≤ T → M.Access A p q x T →
|
| 261 |
+
∃ b : ℕ, N.Within (binaryIn x (fun _ => T)) (M.outcome x T) b ∧
|
| 262 |
+
(b:ℝ) ≤ c*(T:ℝ)^exponent*(Log T)^e := by
|
| 263 |
+
sorry
|
| 264 |
+
|
| 265 |
+
theorem unknown [Fintype X] (A : M.Sym) (p q : ℝ) (hp : 1 ≤ p) (_hq : 1 ≤ q) :
|
| 266 |
+
∃ (N : TM X Empty M.Outcome) (e : ℕ) (c : ℝ), 0 < c ∧
|
| 267 |
+
∀ (x : List X), (∀ T, 2 ≤ T → M.Access A p q x T) →
|
| 268 |
+
∀ (t : ℕ), (M.outcome x t).2 = true →
|
| 269 |
+
∃ b, N.Within (files x) (M.outcome x t) b ∧
|
| 270 |
+
(b:ℝ) ≤ c*((t:ℝ)+2)^exponent*(Log t)^e := by
|
| 271 |
+
sorry
|
| 272 |
+
|
| 273 |
+
end Fifths.Single
|
| 274 |
+
|
| 275 |
+
end OAI
|