Search papers, labs, and topics across Lattice.
This paper introduces Generalized Constraint Projection (GCP), a novel zero-annotation type inference framework for dynamically typed languages that effectively separates four sources of evidence for function parameters. By employing Outline Equational Matching (OEM) and a stable definition-time template, GCP minimizes spurious conflicts and eliminates the need for redundant annotations, allowing for efficient type inference with concrete argument verification and specialization of return types. The framework is instantiated in the Outline dynamic language and successfully applied to unannotated Python code, recovering PEP 484 annotations, thereby demonstrating its practical utility in real-world scenarios.
GCP achieves zero-annotation type inference by reconciling four distinct evidence sources, transforming how we approach type safety in dynamic languages.
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.