Algorithm Search⌘K

Definitioncore

Galois connection

Also called adjunction between posets, Galois insertion.

A pair of monotone maps alpha and gamma between concrete and abstract posets with alpha(x) <= y exactly when x <= gamma(y).

A Galois connection is a pair of monotone maps between a concrete ordered set and an abstract one: the abstraction α\alpha maps a set of states to its best description, and the concretization γ\gamma maps a description to the set of states it allows. The two are tied by one equivalence, α(c)⊑a  ⟺  c≤γ(a)\alpha(c) \sqsubseteq a \iff c \le \gamma(a). From it come the best abstract version of each concrete operation and the transfer of fixed points from the concrete side to the abstract one.

Definition

Let (C,≤)(C, \le) and (A,⊑)(A, \sqsubseteq) be partially ordered sets. In program analysis CC is P(Env)\mathcal{P}(\mathit{Env}) ordered by inclusion, as in the collecting semantics, and AA is an abstract domain. The orders are the Cousot orders: lower is more precise. A pair of maps α:C→A\alpha : C \to A and γ:A→C\gamma : A \to C is a Galois connection when, for all c∈Cc \in C and a∈Aa \in A,

α(c)⊑a  ⟺  c≤γ(a).\alpha(c) \sqsubseteq a \iff c \le \gamma(a).

In words, aa describes cc soundly in the abstract order exactly when cc is inside the meaning of aa in the concrete order. The notation is (C,≤)⇆γα(A,⊑)(C, \le) \underset{\alpha}{\overset{\gamma}{\leftrightarrows}} (A, \sqsubseteq).

Theorem 1 (four conditions). (α,γ)(\alpha, \gamma) is a Galois connection if and only if

  1. α\alpha is monotone,
  2. γ\gamma is monotone,
  3. α(γ(a))⊑a\alpha(\gamma(a)) \sqsubseteq a for every aa, and
  4. c≤γ(α(c))c \le \gamma(\alpha(c)) for every cc.

Proof. Assume the equivalence. For condition 4, put a=α(c)a = \alpha(c): since α(c)⊑α(c)\alpha(c) \sqsubseteq \alpha(c), we get c≤γ(α(c))c \le \gamma(\alpha(c)). For condition 3, put c=γ(a)c = \gamma(a): since γ(a)≤γ(a)\gamma(a) \le \gamma(a), we get α(γ(a))⊑a\alpha(\gamma(a)) \sqsubseteq a. For condition 1, let c≤c′c \le c'. By condition 4, c≤c′≤γ(α(c′))c \le c' \le \gamma(\alpha(c')), and the equivalence turns this into α(c)⊑α(c′)\alpha(c) \sqsubseteq \alpha(c'). For condition 2, let a⊑a′a \sqsubseteq a'. By condition 3, α(γ(a))⊑a⊑a′\alpha(\gamma(a)) \sqsubseteq a \sqsubseteq a', and the equivalence turns this into γ(a)≤γ(a′)\gamma(a) \le \gamma(a').

Now assume the four conditions. If α(c)⊑a\alpha(c) \sqsubseteq a, then c≤γ(α(c))≤γ(a)c \le \gamma(\alpha(c)) \le \gamma(a) by condition 4 and condition 2. If c≤γ(a)c \le \gamma(a), then α(c)⊑α(γ(a))⊑a\alpha(c) \sqsubseteq \alpha(\gamma(a)) \sqsubseteq a by condition 1 and condition 3. □\square

Theorem 2 (each map determines the other). In a Galois connection,

γ(a)=max⁡{c∈C:α(c)⊑a},α(c)=min⁡{a∈A:c≤γ(a)}.\gamma(a) = \max\{ c \in C : \alpha(c) \sqsubseteq a \}, \qquad \alpha(c) = \min\{ a \in A : c \le \gamma(a) \}.

So if (α,γ1)(\alpha, \gamma_1) and (α,γ2)(\alpha, \gamma_2) are both Galois connections, then γ1=γ2\gamma_1 = \gamma_2, and the same holds for α\alpha.

Proof. By condition 3, γ(a)\gamma(a) is in the set {c:α(c)⊑a}\{ c : \alpha(c) \sqsubseteq a \}. By the equivalence, each cc in the set has c≤γ(a)c \le \gamma(a). So γ(a)\gamma(a) is the greatest element of the set. The formula for α\alpha is the dual argument with condition 4. A greatest element is unique, so γ\gamma depends only on α\alpha. □\square

Theorem 3 (joins and meets). α\alpha preserves every join that exists in CC, and γ\gamma preserves every meet that exists in AA. In particular α(⊥C)=⊥A\alpha(\bot_C) = \bot_A when ⊥C\bot_C exists.

Proof. Let S⊆CS \subseteq C have a join ⋁S\bigvee S. For every aa,

α(⋁S)⊑a  ⟺  ⋁S≤γ(a)  ⟺  ∀s∈S:s≤γ(a)  ⟺  ∀s∈S:α(s)⊑a.\alpha\Bigl(\bigvee S\Bigr) \sqsubseteq a \iff \bigvee S \le \gamma(a) \iff \forall s \in S : s \le \gamma(a) \iff \forall s \in S : \alpha(s) \sqsubseteq a.

So the upper bounds of α(S)\alpha(S) are exactly the elements above α(⋁S)\alpha(\bigvee S), and α(⋁S)\alpha(\bigvee S) is the join of α(S)\alpha(S). The case of γ\gamma is dual. For S=∅S = \emptyset the join is ⊥C\bot_C, and the claim gives α(⊥C)=⊥A\alpha(\bot_C) = \bot_A. □\square

The converse holds for complete lattices: if α\alpha preserves all joins, then γ(a)=⋁{c:α(c)⊑a}\gamma(a) = \bigvee \{ c : \alpha(c) \sqsubseteq a \} makes a Galois connection. Indeed α(c)⊑a\alpha(c) \sqsubseteq a puts cc in the set, so c≤γ(a)c \le \gamma(a); and if c≤γ(a)c \le \gamma(a), then α(c)⊑α(γ(a))=⨆{α(c′):α(c′)⊑a}⊑a\alpha(c) \sqsubseteq \alpha(\gamma(a)) = \bigsqcup \{ \alpha(c') : \alpha(c') \sqsubseteq a \} \sqsubseteq a. So to give a Galois connection between complete lattices, it is enough to give an α\alpha that preserves joins.

Closure. From conditions 1, 3 and 4, α∘γ∘α=α\alpha \circ \gamma \circ \alpha = \alpha: the inequality α⊑αγα\alpha \sqsubseteq \alpha \gamma \alpha is condition 4 under the monotone α\alpha, and αγ(α(c))⊑α(c)\alpha \gamma (\alpha(c)) \sqsubseteq \alpha(c) is condition 3. Dually γ∘α∘γ=γ\gamma \circ \alpha \circ \gamma = \gamma. So γ∘α\gamma \circ \alpha is an upper closure on CC: monotone, extensive (c≤γα(c)c \le \gamma\alpha(c)) and idempotent. It maps each set of states to the smallest set that the domain can express.

Galois insertion. A Galois connection is a Galois insertion when α∘γ=idA\alpha \circ \gamma = \mathrm{id}_A, the special case where condition 3 holds with equality. These are equivalent:

  1. α∘γ=idA\alpha \circ \gamma = \mathrm{id}_A;
  2. α\alpha is onto;
  3. γ\gamma is one to one.

Proof. From 1, each aa equals α(γ(a))\alpha(\gamma(a)), so α\alpha is onto; and γ(a)=γ(b)\gamma(a) = \gamma(b) gives a=αγ(a)=αγ(b)=ba = \alpha\gamma(a) = \alpha\gamma(b) = b. From 2, write a=α(c)a = \alpha(c); then αγ(a)=αγα(c)=α(c)=a\alpha\gamma(a) = \alpha\gamma\alpha(c) = \alpha(c) = a. From 3, γ(αγ(a))=γ(a)\gamma(\alpha\gamma(a)) = \gamma(a) by the closure identity, so αγ(a)=a\alpha\gamma(a) = a. □\square

In an insertion no two abstract elements have the same meaning, so the domain has no redundant elements. Every Galois connection gives an insertion when AA is cut down to the image of α\alpha; this keeps one element for each meaning.

The best transformer. Let f:C→Cf : C \to C be monotone, for example the concrete post\mathit{post} of an instruction. Call g:A→Ag : A \to A sound for ff when f∘γ≤γ∘gf \circ \gamma \le \gamma \circ g pointwise. Then:

  • α∘f∘γ\alpha \circ f \circ \gamma is sound: f(γ(a))≤γ(α(f(γ(a))))f(\gamma(a)) \le \gamma(\alpha(f(\gamma(a)))) by condition 4.
  • It is the most precise sound map: for each aa, α(f(γ(a)))⊑g(a)\alpha(f(\gamma(a))) \sqsubseteq g(a) if and only if f(γ(a))≤γ(g(a))f(\gamma(a)) \le \gamma(g(a)), by the equivalence. So gg is sound exactly when α∘f∘γ⊑g\alpha \circ f \circ \gamma \sqsubseteq g.
  • If gg is monotone, soundness is the same as α∘f⊑g∘α\alpha \circ f \sqsubseteq g \circ \alpha. From αf⊑gα\alpha f \sqsubseteq g \alpha: αfγ⊑gαγ⊑g\alpha f \gamma \sqsubseteq g \alpha \gamma \sqsubseteq g by condition 3 and the monotone gg. From αfγ⊑g\alpha f \gamma \sqsubseteq g: αf⊑αfγα⊑gα\alpha f \sqsubseteq \alpha f \gamma \alpha \sqsubseteq g \alpha by condition 4 and the monotone αf\alpha f.

The best transformer is a specification. It may not be computable in a closed form, and a real domain often uses a sound map that is less precise but faster.

Theorem 4 (fixed point transfer). Let CC and AA be complete lattices, and let f:C→Cf : C \to C and g:A→Ag : A \to A be monotone with α∘f⊑g∘α\alpha \circ f \sqsubseteq g \circ \alpha. Then

α(lfp f)⊑lfp g,equivalentlylfp f≤γ(lfp g).\alpha(\mathrm{lfp}\, f) \sqsubseteq \mathrm{lfp}\, g, \qquad \text{equivalently} \qquad \mathrm{lfp}\, f \le \gamma(\mathrm{lfp}\, g).

If moreover α∘f=g∘α\alpha \circ f = g \circ \alpha, then α(lfp f)=lfp g\alpha(\mathrm{lfp}\, f) = \mathrm{lfp}\, g.

Proof. Let a=lfp ga = \mathrm{lfp}\, g. By the last point above, f(γ(a))≤γ(g(a))=γ(a)f(\gamma(a)) \le \gamma(g(a)) = \gamma(a). So γ(a)\gamma(a) is an element xx with f(x)≤xf(x) \le x, and by the Knaster-Tarski theorem the least fixed point of ff is below it: lfp f≤γ(a)\mathrm{lfp}\, f \le \gamma(a). The equivalence gives α(lfp f)⊑a\alpha(\mathrm{lfp}\, f) \sqsubseteq a. For the second claim, g(α(lfp f))=α(f(lfp f))=α(lfp f)g(\alpha(\mathrm{lfp}\, f)) = \alpha(f(\mathrm{lfp}\, f)) = \alpha(\mathrm{lfp}\, f), so α(lfp f)\alpha(\mathrm{lfp}\, f) is a fixed point of gg, and lfp g\mathrm{lfp}\, g is below it. □\square

When α∘f=g∘α\alpha \circ f = g \circ \alpha, the abstraction is called complete for ff: the abstract least fixed point loses nothing beyond what α\alpha loses on the exact answer. This is rare. Most transfer functions give only the inequality, and a widening then gives an element above lfp g\mathrm{lfp}\, g, which is still sound.

Order-reversing form. Ore and the older algebra texts use a pair of order-reversing maps with a⊑α(c)  ⟺  c≤γ(a)a \sqsubseteq \alpha(c) \iff c \le \gamma(a), as between sets of polynomials and sets of their roots. Reverse the order of AA to get the monotone form used here. The monotone form is also called an adjunction between posets, with α\alpha the lower adjoint and γ\gamma the upper adjoint.

Examples and non-examples

Intervals. Let C=P(Z)C = \mathcal{P}(\mathbb{Z}) and let AA be the interval domain with bounds in Z∪{−∞,+∞}\mathbb{Z} \cup \{-\infty, +\infty\}. Put γ([l,u])={x:l≤x≤u}\gamma([l, u]) = \{ x : l \le x \le u \}, γ(⊥)=∅\gamma(\bot) = \emptyset, α(∅)=⊥\alpha(\emptyset) = \bot and α(S)=[inf⁡S,sup⁡S]\alpha(S) = [\inf S, \sup S] otherwise. Then α(S)⊑[l,u]\alpha(S) \sqsubseteq [l, u] says l≤inf⁡Sl \le \inf S and sup⁡S≤u\sup S \le u, which says S⊆γ([l,u])S \subseteq \gamma([l, u]). So this is a Galois connection. It is an insertion, because α\alpha is onto: [l,u]=α(γ([l,u]))[l, u] = \alpha(\gamma([l, u])). For S={1,4,9}S = \{1, 4, 9\}, α(S)=[1,9]\alpha(S) = [1, 9] and γ(α(S))={1,…,9}\gamma(\alpha(S)) = \{1, \dots, 9\}, which shows that condition 4 can be strict. The best transformer for x↦x⋅xx \mapsto x \cdot x applied to [−2,3][-2, 3] is α({0,1,4,9})=[0,9]\alpha(\{0, 1, 4, 9\}) = [0, 9], while the interval product of [−2,3][-2, 3] with itself gives [−6,9][-6, 9], because it does not know that both factors are the same number.

A connection that is not an insertion. Take two names and the plain product of two interval domains, without identifying the pairs that contain ⊥\bot. Then γ(⊥,[0,1])=∅=γ(⊥,⊥)\gamma(\bot, [0, 1]) = \emptyset = \gamma(\bot, \bot), so γ\gamma is not one to one, and α(γ(⊥,[0,1]))=(⊥,⊥)≠(⊥,[0,1])\alpha(\gamma(\bot, [0, 1])) = (\bot, \bot) \ne (\bot, [0, 1]). The pair is still a Galois connection: the four conditions hold. Identify every pair that has a ⊥\bot component with one bottom element, and the result is an insertion. The reduced product does the same in general, with a reduction operator.

Non-example: no best abstraction. Let CC be the subsets of the real plane and AA the closed convex polyhedra, with γ\gamma the inclusion, as in the polyhedra domain. The disk D={(x,y):x2+y2≤1}D = \{ (x, y) : x^2 + y^2 \le 1 \} has no least polyhedron above it. Take any polyhedron P⊇DP \supseteq D. The boundary of a polyhedron is made of finitely many line segments, and the boundary of DD is a circle, so P≠DP \ne D, and some point pp is in PP and not in DD. The disk is closed and convex, so a line separates pp from DD: there is a closed half-plane HH with D⊆HD \subseteq H and p∉Hp \notin H. Then P∩HP \cap H is a polyhedron above DD and strictly below PP. So min⁡{a:D⊆γ(a)}\min\{ a : D \subseteq \gamma(a) \} does not exist, and by Theorem 2 no α\alpha makes a Galois connection with this γ\gamma. The domain is still usable: it only needs γ\gamma and sound operations.

Non-example: monotone maps that do not match. On C=P(Z)C = \mathcal{P}(\mathbb{Z}) and the interval domain, keep γ\gamma and take α′(S)=⊤\alpha'(S) = \top for every nonempty SS. Both maps are monotone and condition 4 holds, but α′(γ([0,1]))=⊤⋢[0,1]\alpha'(\gamma([0, 1])) = \top \not\sqsubseteq [0, 1], so condition 3 fails. Then [0,1][0, 1] describes {0,1}\{0, 1\} soundly, but α′({0,1})⊑[0,1]\alpha'(\{0, 1\}) \sqsubseteq [0, 1] is false, and the equivalence breaks. By Theorem 2 the only α\alpha that works with this γ\gamma is the one in the interval example.

  • Abstract domain: the abstract side; a domain needs γ\gamma and sound operations, and a Galois connection is the extra structure that gives best descriptions.
  • Collecting semantics: the concrete side, C=P(Env)C = \mathcal{P}(\mathit{Env}) at each point.
  • Abstract interpretation: the general technique, which uses Theorem 4 to relate the abstract fixed point to the concrete one.
  • Knaster-Tarski theorem and fixed point: the facts about least fixed points that the transfer theorem uses.
  • Join-semilattice: Theorem 3 says that α\alpha is a join homomorphism.
  • Reduced product: a product of two Galois connections, cut down to an insertion by a reduction.
  • Widening operator: the way to reach an element above lfp g\mathrm{lfp}\, g when the abstract lattice has infinite chains.

References

  1. Patrick Cousot and Radhia Cousot, Systematic design of program analysis frameworks, POPL 1979, pages 269 to 282, the Galois connection between the concrete and the abstract lattice, the best approximation of the concrete operations, and the design of analyses from it
  2. Patrick Cousot and Radhia Cousot, Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints, POPL 1977, pages 238 to 252, the abstraction and concretization functions that relate an abstract interpretation to the static semantics
  3. Patrick Cousot and Radhia Cousot, Abstract interpretation frameworks, Journal of Logic and Computation 2(4), 1992, pages 511 to 547, the comparison of the framework with a Galois connection and the frameworks with a concretization function only
  4. B. A. Davey and H. A. Priestley, Introduction to Lattices and Order, second edition, Cambridge University Press, 2002, Chapter 7 (Complete lattices and Galois connections), the section on Galois connections
  5. Flemming Nielson, Hanne Riis Nielson and Chris Hankin, Principles of Program Analysis, Springer, 1999, Chapter 4 (Abstract Interpretation), the sections on Galois connections, Galois insertions and induced operations

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/733ZE7/text.yaml