Compiling a polynomial-time word-list evaluator to bounded RAM
ProvedWordRAM.Functional.compile_word_list_evaluatoralgorithmscomputational-complexityword-ram
Fix a finite functional program and designate its entry point. Suppose a call on a nonempty list of words returns an output list within a polynomial budget T, and the output contains at most T words. There is one bounded imperative program for that evaluator and budget polynomial. It reads the encoded input and writes exactly the output, in time linear in T plus the input length. The theorem also gives explicit bounds on the work arrays and intermediate words, including the size of the largest input word. This allows the compiled evaluator to be called as a subroutine of a larger word-RAM algorithm.
Preamble
import Definitions.Def_BodlaenderKloks_FunctionalMachine import Definitions.Def_EdgeSublinearMWIS_Main_NativeSchemeInterfaces
Formal statement
namespace WordRAM.Functional
open Lax689794Proofs.Fun Lax689794Proofs.Fun.ToVal
open Lax808846Proofs.Imp Lax808846Proofs.Reasoning
theorem compile_word_list_evaluator (Δ : ℕ → Option Tm) (N entry : ℕ) :
∃ programWords : ℕ, ∀ A h : ℕ, ∃ machine : Com × ℕ, ∀ input output : List ℕ,
let work := A*(input.length+1)^h
let word := (input.foldr max 0+work+2)^2+1
let limit := 2*word+4*(work+input.length+8)+machine.2
let extent := (word+input.length+1)+programWords+word+3*work+3+1
(∀ f, N ≤ f → Δ f=none) → 1 ≤ A → input≠[] →
Runs Δ word entry [toVal input] (toVal output) work → output.length ≤ work →
∃ final, Run limit machine.1 ((initEnv (fun _ => extent) input).setVar "tot" input.length) final
(machine.2*(work+input.length+1)) ∧ final.out=output := by sorry
end WordRAM.FunctionalSource
Bounded IMP compilation of the functional machine used for preprocessing in S. Kumabe and Y. Uezato, On the Complexity of the Matching Problem of Regular Expressions with Backreferences. https://arxiv.org/abs/2605.07289