math / data /lean /ComparatorChallenges /TreeEdit.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
2.06 kB
import Mathlib
namespace OAI
namespace TreeEdit
universe u
/-- A single unit-cost insertion, deletion or substitution, at any position. -/
inductive EditStep {Ξ± : Type u} : List Ξ± β†’ List Ξ± β†’ Prop
| insert (p q : List Ξ±) (a : Ξ±) : EditStep (p ++ q) (p ++ a :: q)
| delete (p q : List Ξ±) (a : Ξ±) : EditStep (p ++ a :: q) (p ++ q)
| substitute (p q : List Ξ±) (a b : Ξ±) : EditStep (p ++ a :: q) (p ++ b :: q)
/-- A script of precisely `n` edits. There is no restriction on its intermediate lengths. -/
inductive EditScript {Ξ± : Type u} : List Ξ± β†’ List Ξ± β†’ β„• β†’ Prop
| nil (x : List Ξ±) : EditScript x x 0
| cons {x y z : List Ξ±} {n : β„•} :
EditStep x y β†’ EditScript y z n β†’ EditScript x z (n + 1)
/-- Ordinary unit-cost edit distance. The set is nonempty (delete then insert). -/
noncomputable def ed {Ξ± : Type u} (x y : List Ξ±) : β„• :=
sInf {n | EditScript x y n}
/-- The full infinite-dimensional real ℓ₁ space. -/
abbrev RealL1 := lp (fun _ : β„• => ℝ) 1
/-- Product of the two maximal pairwise distance ratios. -/
noncomputable def distortion (W : Finset (List Bool)) (f : W β†’ RealL1) : ℝ :=
sSup {r : ℝ | βˆƒ x y : W, x β‰  y ∧
r = dist (f x) (f y) / (ed x.val y.val : ℝ)} *
sSup {r : ℝ | βˆƒ x y : W, x β‰  y ∧
r = (ed x.val y.val : ℝ) / dist (f x) (f y)}
/-- Infimum over all injective ℓ₁ maps, used on finite sets with at least two points. -/
noncomputable def c1 (W : Finset (List Bool)) : ℝ :=
sInf {D : ℝ | βˆƒ f : W β†’ RealL1, Function.Injective f ∧ distortion W f = D}
/-- The binary main endpoint, for every sufficiently large cap (natural logarithms). -/
def BinaryLowerBound : Prop :=
βˆƒ c : ℝ, 0 < c ∧ βˆƒ dβ‚€ : β„•, βˆ€ d : β„•, dβ‚€ ≀ d β†’
βˆƒ n : β„•, n ≀ d ∧ βˆƒ W : Finset (List Bool),
2 ≀ W.card ∧ (βˆ€ w ∈ W, w.length = n) ∧
Real.exp (c * Real.sqrt (Real.log (d : ℝ) * Real.log (Real.log (d : ℝ)))) ≀ c1 W
theorem binary_torus : BinaryLowerBound := by
sorry
end TreeEdit
end OAI