Find position of a value in a list. Used to change metavar argument indices during assignment.
reverse is necessary because we are directly abstracting over the list.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
ModuleAgda-2.7.0.1Haskell2010
Find position of a value in a list. Used to change metavar argument indices during assignment.
reverse is necessary because we are directly abstracting over the list.
Does the given local meta-variable have a twin meta-variable?
Check whether a meta variable is a place holder for a blocked term.
Performing the meta variable assignment.
The instantiation should not be an InstV and the MetaId should point to something Open or a BlockedConst. Further, the meta variable may not be Frozen.
Skip frozen check. Used for eta expanding frozen metas.
Create a sort meta that cannot be instantiated with Inf (Setω).
Create a sort meta that may be instantiated with Inf (Setω).
Create a sort meta that may be instantiated with Inf (Setω).
newInstanceMeta s t cands creates a new instance metavariable
of type the output type of t with name suggestion s.
Create a new value meta with specific dependencies, possibly η-expanding in the process.
Create a new value meta with specific dependencies without η-expanding.
newValueMetaOfKind :: MonadMetaSolver m=> MetaInfo-> RunMetaOccursCheckIgnored for instance metas.
-> ComparisonIgnored for instance metas.
-> Type-> m (MetaId, Term)Create a new metavariable, possibly η-expanding in the process.
Create a new value meta without η-expanding.
Create a metavariable of record type. This is actually one metavariable for each field.
newRecordMetaCtx :: MetaNameSuggestionName suggestion to be used as a prefix of the name suggestions for the metas that represent each field
-> FrozenShould the meta be created frozen?
-> QNameName of record type
-> ArgsParameters of record type.
-> Telescope-> Permutation-> Args-> TCM TermConstruct a blocked constant if there are constraints.
unblockedTester t returns a Blocker for t.
Auxiliary function used when creating a postponed type checking problem.
Create a postponed type checking problem e : t that waits for type t
to unblock (become instantiated or its constraints resolved).
Create a postponed type checking problem e : t that waits for conditon
unblock. A new meta is created in the current context that has as
instantiation the postponed type checking problem. An UnBlock constraint
is added for this meta, which links to this meta.
Type of the term that is produced by solving the TypeCheckingProblem.
Eta-expand a local meta-variable, if it is of the specified kind. Don't do anything if the meta-variable is a blocked term.
Eta expand blocking metavariables of record type, and reduce the blocked thing.
Miller pattern unification:
assign dir x vs v a solves problem x vs <=(dir) v : a for meta x
if vs are distinct variables (linearity check)
and v depends only on these variables
and does not contain x itself (occurs check).
This is the basic story, but we have added some features:
Pruning.
Benign cases of non-linearity.
vs may contain record patterns.
For a reference to some of these extensions, read Andreas Abel and Brigitte Pientka's TLCA 2011 paper.
Is the given metavariable application secretly an interaction point application? Ugly.
assignMeta m x t ids u solves x ids = u for meta x of type t,
where term u lives in a context of length m.
Precondition: ids is linear.
assignMeta' m x t ids u solves x = [ids]u for meta x of type t,
where term u lives in a context of length m,
and ids is a partial substitution.
Check that the instantiation of the given metavariable fits the type of the metavariable. If the metavariable is not yet instantiated, add a constraint to check the instantiation later.
Check that the instantiation of the metavariable with the given term is well-typed.
Given two types a and b with a <: b, check that a == b.
subtypingForSizeLt :: CompareDirectiondir-> MetaIdThe local meta-variable x.
-> MetaVariableIts associated information mvar <- lookupLocalMeta x.
-> TypeIts type t = jMetaType $ mvJudgement mvar
-> ArgsIts arguments.
-> TermIts to-be-assigned value v, such that x args .dir v
-> (Term -> TCM ())Continuation taking its possibly assigned value.
-> TCM ()Turn the assignment problem _X args <= SizeLt u into
_X args = SizeLt (_Y args) and constraint
_Y args <= u.
expandProjectedVars :: (Pretty a, PrettyTCM a, NoProjectedVar a, ReduceAndEtaContract a, PrettyTCM b, TermSubst b)=> aMeta variable arguments.
-> bRight hand side.
-> (a -> b -> TCM c)-> TCM cEta-expand bound variables like z in X (fst z).
Eta-expand a de Bruijn index of record type in context and passed term(s).
Check whether one of the meta args is a projected var.
noProjectedVar :: a -> Either ProjectedVar ()NoProjectedVar TermDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVarsNoProjectedVar a => NoProjectedVar (Arg a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVarsNoProjectedVar a => NoProjectedVar [a]Defined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVarsNormalize just far enough to be able to eta-contract maximally.
reduceAndEtaContract :: a -> TCM aReduceAndEtaContract TermDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVarsReduceAndEtaContract a => ReduceAndEtaContract (Arg a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVarsReduceAndEtaContract a => ReduceAndEtaContract [a]Defined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVarsTurn non-det substitution into proper substitution, if possible. Otherwise, raise the error.
Exceptions raised when substitution cannot be inverted.
CantInvert TermCannot recover.
NeutralArgA potentially neutral arg: can't invert, but can try pruning.
ProjVar ProjectedVarTry to eta-expand var to remove projs.
Check that arguments args to a metavar are in pattern fragment.
Assumes all arguments already in whnf and eta-reduced.
Parameters are represented as Vars so checkArgs really
checks that all args are Vars and returns the "substitution"
to be applied to the rhs of the equation to solve.
(If args is considered a substitution, its inverse is returned.)
The returned list might not be ordered. Linearity, i.e., whether the substitution is deterministic, has to be checked separately.
If the given metavariable application represents a face, return:
The metavariable information;
The actual face, as an assignment of booleans to variables;
The substitution candidate resulting from inverseSubst'. This
is guaranteed to be linear and deterministic.
The actual substitution, mapping from the constraint context to the metavariable's context.
Put concisely, a face constraint is an equation in the pattern
fragment modulo the presence of endpoints (i0 and i1) in the
telescope. In more detail, a face constraint has the form
?0 Δ (i = i0) (j = i0) Γ (k = i1) Θ (l = i0) = twhere all the greek letters consist entirely of distinct bound variables (and, of course, arbitrarily many endpoints are allowed between each substitution fragment).
Record a "face" equation onto an interaction point into the actual
interaction point boundary. Takes all the same arguments as
assignMeta'.
Turn open metas into postulates.
Preconditions:
We are inTopContext.
envCurrentModule is set to the top-level module.
Sort metas in dependency order.