The target of the function we are checking.
Constructors
TargetDef QNameThe target of recursion is a
record,data, or unreducibleDef.TargetRecordWe are termination-checking a record.
TargetOtherNone of the above two or unknown.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
ModuleAgda-2.7.0.1Haskell2010
The monad for the termination checker.
The termination monad TerM is an extension of
the type checking monad TCM by an environment
with information needed by the termination checker.
The target of the function we are checking.
TargetDef QNameThe target of recursion is a record, data, or unreducible Def.
TargetRecordWe are termination-checking a record.
TargetOtherNone of the above two or unknown.
The current guardedness level.
The termination environment.
TerEnvterUseDotPatterns :: BoolAre we mining dot patterns to find evindence of structal descent?
terSizeSuc :: Maybe QNameThe name of size successor, if any.
terSharp :: Maybe QNameThe name of the delay constructor (sharp), if any.
terCutOff :: CutOffDepth at which to cut off the structural order.
terCurrent :: QNameThe name of the function we are currently checking.
terMutual :: MutualNamesThe names of the functions in the mutual block we are checking. This includes the internally generated functions (with, extendedlambda, coinduction).
terUserNames :: Set QNameThe list of name actually appearing in the file (abstract syntax). Excludes the internally generated functions.
terHaveInlinedWith :: BoolDoes the actual clause result from with-inlining? (If yes, it may be ill-typed.)
terTarget :: TargetTarget type of the function we are currently termination checking. Only the constructors of Target are considered guarding.
terMaskArgs :: [Bool]terMaskResult :: BoolOnly consider guardedness if False (not masked).
_terSizeDepth :: IntHow many SIZELT relations do we have in the context
(= clause telescope). Used to approximate termination
for metas in call args.
terPatterns :: MaskedDeBruijnPatternsThe patterns of the clause we are checking.
terPatternsRaise :: !IntNumber of additional binders we have gone under (and consequently need to raise the patterns to compare to terms). Updated during call graph extraction, hence strict.
terGuarded :: !GuardedThe current guardedness status. Changes as we go deeper into the term. Updated during call graph extraction, hence strict.
terUseSizeLt :: BoolWhen extracting usable size variables during construction of the call matrix, can we take the variable for use with SIZELT constraints from the context? Yes, if we are under an inductive constructor. No, if we are under a record constructor. (See issue #1015).
terUsableVars :: VarSetPattern variables that can be compared to argument variables using SIZELT.
An empty termination environment.
Values are set to a safe default meaning that with these initial values the termination checker will not miss termination errors it would have seen with better settings of these values.
Values that do not have a safe default are set to
IMPOSSIBLE.
Termination monad service class.
Monad TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadFunctor TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadMonadFail TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadApplicative TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadMonadIO TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadMonadBench TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadHasOptions TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadMonadReduce TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadMonadTCEnv TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadMonadTCM TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadMonadTCState TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadReadTCState TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadHasBuiltins TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadMonadAddContext TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadMonadDebug TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadPureTCM TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadHasConstInfo TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadMonadStatistics TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadMonadTer TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadMonadError TCErr TerMDefined in Agda-2.7.0.1 · Agda.Termination.MonadSemigroup m => Semigroup (TerM m)Defined in Agda-2.7.0.1 · Agda.Termination.Monad(Semigroup m, Monoid m) => Monoid (TerM m)Defined in Agda-2.7.0.1 · Agda.Termination.Monadtype BenchPhase TerM = PhaseDefined in Agda-2.7.0.1 · Agda.Termination.MonadGeneric run method for termination monad.
Run TerM computation in default environment (created from options).
Lens for _terSizeDepth.
Lens for terUsableVars.
Lens for terUseSizeLt.
Compute usable vars from patterns and run subcomputation.
Set terUseSizeLt when going under constructor c.
Set terUseSizeLt for arguments following projection q.
We disregard j<i after a non-coinductive projection.
However, the projection need not be recursive (Issue 1470).
For termination checking purposes flat should not be considered a projection. That is, it flat doesn't preserve either structural order or guardedness like other projections do. Andreas, 2012-06-09: the same applies to projections of recursive records.
Check whether a projection belongs to a coinductive record and is actually recursive. E.g. @ isCoinductiveProjection (Stream.head) = return False
isCoinductiveProjection (Stream.tail) = return True @
How long is the path to the deepest atomic pattern?
A dummy pattern used to mask a pattern that cannot be used for structural descent.
Extract variables from DeBruijnPatterns that could witness a decrease via a SIZELT constraint.
These variables must be under an inductive constructor (with no record constructor in the way), or after a coinductive projection (with no inductive one in the way).
usableSizeVars :: a -> TerM VarSetUsableSizeVars DeBruijnPatternDefined in Agda-2.7.0.1 · Agda.Termination.MonadUsableSizeVars MaskedDeBruijnPatternsDefined in Agda-2.7.0.1 · Agda.Termination.MonadUsableSizeVars (Masked DeBruijnPattern)Defined in Agda-2.7.0.1 · Agda.Termination.MonadUsableSizeVars [DeBruijnPattern]Defined in Agda-2.7.0.1 · Agda.Termination.MonadFunctor MaskedDefined in Agda-2.7.0.1 · Agda.Termination.MonadFoldable MaskedDefined in Agda-2.7.0.1 · Agda.Termination.MonadTraversable MaskedDefined in Agda-2.7.0.1 · Agda.Termination.MonadDecoration MaskedDefined in Agda-2.7.0.1 · Agda.Termination.MonadUsableSizeVars MaskedDeBruijnPatternsDefined in Agda-2.7.0.1 · Agda.Termination.MonadEq a => Eq (Masked a)Defined in Agda-2.7.0.1 · Agda.Termination.MonadOrd a => Ord (Masked a)Defined in Agda-2.7.0.1 · Agda.Termination.MonadShow a => Show (Masked a)Defined in Agda-2.7.0.1 · Agda.Termination.MonadPrettyTCM a => PrettyTCM (Masked a)Defined in Agda-2.7.0.1 · Agda.Termination.MonadPrint masked things in double parentheses.
UsableSizeVars (Masked DeBruijnPattern)Defined in Agda-2.7.0.1 · Agda.Termination.MonadShow CallPathDefined in Agda-2.7.0.1 · Agda.Termination.MonadSemigroup CallPathDefined in Agda-2.7.0.1 · Agda.Termination.MonadMonoid CallPathDefined in Agda-2.7.0.1 · Agda.Termination.MonadPretty CallPathDefined in Agda-2.7.0.1 · Agda.Termination.MonadOnly show intermediate nodes. (Drop last CallInfo).
The calls making up the call path.
A very crude way of estimating the SIZELT chains
i > j > k in context. Returns 3 in this case.
Overapproximates.
terSetSizeDepth :: b -> TerM a -> TerM aTerSetSizeDepth ListTelDefined in Agda-2.7.0.1 · Agda.Termination.MonadTerSetSizeDepth TelescopeDefined in Agda-2.7.0.1 · Agda.Termination.Monad