HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

ModuleAgda-2.7.0.1Haskell2010

Agda.TypeChecking.Injectivity

Injectivity, or more precisely, "constructor headedness", is a property of functions defined by pattern matching that helps us solve constraints involving blocked applications of such functions. Blocked shall mean here that pattern matching is blocked on a meta variable, and constructor headedness lets us learn more about that meta variable.

Consider the simple example: isZero : Nat -> Bool isZero zero = true isZero (suc n) = false This function is constructor-headed, meaning that all rhss are headed by a distinct constructor. Thus, on a constraint like isZero ?X = false : Bool involving an application of isZero that is blocked on meta variable ?X, we can exploit injectivity and learn that ?X = suc ?Y for a new meta-variable ?Y.

Which functions qualify for injectivity?

  1. The function needs to have at least one non-absurd clause that has a proper match, meaning that the function can actually be blocked on a meta. Proper matches are these patterns:

  • data constructor (ConP, but not record constructor)

  • literal (LitP)

  • HIT-patterns (DefP)

Projection patterns (ProjP) are excluded because metas cannot occupy their place!

  1. All the clauses that satisfy (1.) need to be headed by a distinct constructor.

  • 1 type
  • 14 values
  • PackageAgda-2.7.0.1
  • Exports15
  • LanguageHaskell2010
  • LicenceMIT
  • SourceInjectivity.hs
valueisUnstableDef :: PureTCM m => QName -> m Bool
#

Is this a matchable definition, or constructor, which reduces based on interval substitutions?

valueheadSymbol' :: (PureTCM m, MonadError TCErr m) => Term -> m (Maybe TermHead)
#

Do a full whnf and treat neutral terms as rigid. Used on the arguments to an injective functions and to the right-hand side. Only returns heads which are stable under interval substitution, i.e. NOT path constructors or generated hcomp/transp!