🤖 AI Summary
This paper addresses uniform random sampling without replacement of well-typed functions in a first-order simply typed functional language. We propose a syntax-directed, exact reduction from type systems to context-free grammars (CFGs), and build upon it a finite automaton-based framework for construction and counting, enabling exact, duplicate-free, and uniform sampling of all well-typed functions inhabiting a given type. To our knowledge, this is the first approach achieving fixed-parameter tractable (FPT-trackable) sampling while preserving both type safety and semantic completeness. Our reduction framework unifies formal language theory and type theory, ensuring theoretical rigor and practical scalability. Experimental evaluation confirms the correctness, completeness, and polynomial-time efficiency of the algorithm.
📝 Abstract
We describe an exact sampler for a simply-typed, first-order functional programming language. Given an acyclic finite automaton, $α_{varnothing}$, it samples a random function uniformly without replacement from well-typed functions in $mathcal{L}(α_{varnothing})$. This is achieved via a fixed-parameter tractable reduction from a syntax-directed type system to a context-free grammar, preserving type soundness and completeness w.r.t. $mathcal{L}(α_{varnothing})$, while retaining the robust metatheory of formal languages.