Generalized Constraint Projection: Four-Dimensional Type Inference for Dynamic Languages

📅 2026-07-21
📈 Citations: 0
✨ Influential: 0
📄 PDF
🤖 AI Summary
This work addresses the challenge in dynamic languages where heterogeneous type evidence for function parameters—such as internal assignments, explicit declarations, contextual requirements, and structural operations—often leads to conflicts or redundancy when processed jointly. The paper proposes a Generalized Constraint Projection (GCP) framework that separates these four evidence sources into monotonic slots at definition time and validates arguments via fresh projection sessions at call time, simultaneously specializing return types. A key innovation is the introduction of Outline Equational Matching (OEM), a structure that integrates preorder relations with a future-this receiver mechanism, enabling—for the first time—annotation-free, modular, and convergent type inference. Implemented in the Outline language, the approach accurately reconstructs PEP 484 type annotations from unannotated Python code, supports downstream compilation, and formally guarantees convergence, type preservation, and projection–evaluation consistency.
📝 Abstract
Type inference for dynamically typed languages must reconcile four distinct sources of evidence for function parameters: internal assignments, explicit declarations, contextual requirements, and structural operations. Existing systems often merge these sources into one constraint set, causing spurious conflicts or requiring redundant annotations. We present Generalized Constraint Projection (GCP), a zero-annotation inference framework that stores the four sources in separate monotone slots on a stable definition-time template and checks each call in a fresh projection session. Ordinary calls verify concrete arguments and specialize return types without modifying the template, while currying produces residual projected functions. GCP uses Outline Equational Matching (OEM), a structural compatibility preorder with an open bidirectional delegation protocol, and future this, a receiver-preserving extension for subtype-refining fluent APIs. On the strict success fragment of a finite-height type preorder, we prove monotonicity, local and global convergence in $O(Nh_T)$ effective updates, conditional projection-obligation soundness, projection termination, multi-module convergence, and order independence under fair monotone iteration. For the pure, recursion-free core Outline0, we additionally prove big-step evaluation definedness, type preservation, runtime receiver retention, and projection-evaluation coherence. We instantiate GCP in the Outline dynamic language as a typed substrate for ontology worlds and apply it to unannotated Python source to recover PEP 484 annotations for downstream compilation.
Problem

Research questions and friction points this paper is trying to address.

type inference
dynamic languages
constraint projection
function parameters
type annotations
Innovation

Methods, ideas, or system contributions that make the work stand out.

Generalized Constraint Projection
Type Inference
Dynamic Languages
Outline Equational Matching
Zero-Annotation
🔎 Similar Papers
Q
Qunhui Zhang
School of Software, Shanghai Jiao Tong University