Skip to content

Polyvariance

A static-analysis design that retains distinct abstract approximations for selected calling contexts or value origins instead of merging them into one state.

Version
v1 · 2026-10-03 · History
Domain-specific #
13504
Domain group
Applied Sciences & Engineering
Origin domain
Computer Science & Software Engineering
Subdomains
Static Program Analysis, Abstract Interpretation → Computer Science & Software Engineering
Aliases
Polyvariant analysis

Core Idea

A static analyzer cannot run a program on every possible input, so it tracks approximate facts such as “this value might be positive” or “this pointer might refer to these objects.” If it combines every use of one function too early, facts from one caller can contaminate the result for another. Polyvariance retains separate approximate states for selected contexts or value origins. A call site, receiver object, or abstract input can supply the key; none is the only valid choice. The analyzer still has to cover every feasible execution soundly.

How would you explain it like I'm…

Separate Notes Helper

Some computer tools study a program without running it, to guess what it might do. If lots of different parts of the program use the same helper, the tool can either mix all their notes into one messy pile or keep a separate note for each. Keeping separate notes so the answers don't get mixed up is called polyvariance. But too many notes can make the tool slow.

Keeping Guesses Apart

Some computer tools check a program for problems without running it, by making careful guesses about what values could show up. When the same piece of code is used from several places, a simple tool mixes all those uses into one guess, which can create combinations that could never really happen and cause false alarms. Polyvariance means the tool keeps separate guesses for different uses, for example one for each place the code is called from. That makes the answers sharper, but it also means more work and more memory. The guesses must still cover everything that could really happen.

Context-Sensitive Program Analysis

Polyvariance is a choice in static program analysis, which reasons about a program's possible behaviors without running it. A monovariant analysis keeps one approximate (abstract) description for each function or program point, merging the information from all callers and handing the merged result back to each, which can create impossible combinations. A polyvariant analysis keeps multiple descriptions, distinguished by some context: the recent call site, where the receiver object was created, or the abstract argument values. Analyzing a function once per call site is a common example, but it is only one policy. More contexts can reduce false alarms, but they can also blow up the number of states, time, and memory. Any polyvariant analysis must still soundly cover all feasible executions; just dropping inconvenient flows isn't valid.

 

Polyvariance is a design choice in static analysis to maintain multiple abstract approximations of a shared program function, point, or value origin when different uses carry meaningfully different information. A monovariant analysis joins all callers' abstract inputs into one state and returns the joined result to each, introducing spurious flows. A polyvariant analysis uses a context policy, such as call-site sensitivity, object (receiver-origin) sensitivity, or argument-value sensitivity, to keep approximations separate; in abstract-machine formulations, the policy can be expressed through abstract address allocation. Polyvariance is best seen as the degree to which an analysis differentiates approximations, with these policies as alternative choices of which distinctions to preserve, not separate definitions; per-call-site analysis is only one instance. The benefit is conditional: more contexts can reduce spurious joins and false alarms but can also blow up states, time, and memory without helping a given client query. Soundness remains required, so a result that simply discards flows is not a valid polyvariant analysis.

Scope of Application

This is a computer-science technique within interprocedural data-flow, control-flow, points-to, type and related static analyses. For instance, two calls with different abstract signs can be kept apart, while an object-oriented pointer analysis may distinguish receiver-related contexts. More contexts can improve useful precision but cost time and memory. A mere human habit of “considering context” is an analogy, not program-analysis polyvariance.

Clarity

Polyvariance helps explain an “unknown” analysis result: is the program genuinely ambiguous, or did the analysis merge unlike callers? Inspecting the context key and the separate states reveals where the uncertainty arose. It also distinguishes the number of dynamic calls from the number of abstract variants retained.

Manages Complexity

Rather than represent every execution history, the analyzer chooses a finite or tractable distinction policy, such as the last call site or a short call string. The resulting contexts compress histories while preserving selected correlations. Too few distinctions produce false joins; too many can make analysis impractical.

Abstract Reasoning

When an analyzer produces a false positive, find the join that mixed incompatible facts. Try a context key that separates those cases, verify each new state still covers its assigned feasible executions, then measure the useful precision gain against extra computation. A key is justified by the client question, not by the mere possibility of creating more variants.

Knowledge Transfer

The same design question applies across kinds of static analysis: what facts must remain separate to answer the query without an explosion of states? The broader idea of partitioning information appears elsewhere, but this entry remains domain-specific because it requires abstract program states, control-flow propagation and soundness over possible executions. See the staged V2 for mapped cases and source limitations.

Neighborhood in Abstraction Space

Polyvariance sits in a moderately populated region (54th percentile for distinctiveness): it has near-neighbors but no dense thicket of look-alikes.

Family — Logical Inference, Modality & Conditional Structures (28 abstractions)

Nearest neighbors

Computed from structural-signature embeddings · 2026-11-14