cfahlgren1's picture
download
raw
3.59 kB
import Mathlib
namespace OAI
namespace TreeEdit
universe u v
/-- 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
/-- The length of a longest arbitrary common subsequence. -/
noncomputable def lcs {α : Type u} (x y : List α) : ℕ :=
sSup {n | ∃ z : List α, z.Sublist x ∧ z.Sublist y ∧ z.length = n}
/-- One-sided deficit; used below only when the two lengths agree. -/
noncomputable def deficit {α : Type u} (x y : List α) : ℕ := x.length - lcs x y
/-- Fixed-length words, with symbols at every position arbitrary. -/
abbrev Word (α : Type u) (n : ℕ) := {x : List α // x.length = n}
/-- The concatenation extension of a fixed-width symbol code, on *all* finite words. -/
def encode {α : Type u} {β : Type v} {P : ℕ} (c : α → Word β P) (x : List α) : List β :=
x.flatMap (fun a => (c a).val)
/-- Exact polynomial-width code endpoint, including the stronger deficit inequality. -/
def FixedLengthBinaryConversion : Prop :=
∃ M₀ : ℕ, ∀ M : ℕ, M₀ ≤ M → ∀ (Γ : Type u) [Fintype Γ],
1 ≤ Fintype.card Γ → Fintype.card Γ ≤ M →
∃ c : Γ → Word Bool (M ^ 2), ∀ x y : Word Γ M,
(encode c x.val).length = M ^ 3 ∧
(encode c y.val).length = M ^ 3 ∧
((M ^ 2 : ℕ) : ℝ) / 804 * (ed x.val y.val : ℝ) ≤
(ed (encode c x.val) (encode c y.val) : ℝ) ∧
(ed (encode c x.val) (encode c y.val) : ℝ) ≤
((M ^ 2 : ℕ) : ℝ) * (ed x.val y.val : ℝ) ∧
((M ^ 2 : ℕ) : ℝ) / 402 * (deficit x.val y.val : ℝ) ≤
(deficit (encode c x.val) (encode c y.val) : ℝ)
def vectorWord {P : ℕ} (v : Fin P → Bool) : Word Bool P :=
⟨List.ofFn v, List.length_ofFn⟩
end TreeEdit
end OAI

Xet Storage Details

Size:
3.59 kB
·
Xet hash:
e78eb600c0e830e9f857bed239423f4968be6e298bf22e5b34821003227432a6

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.