ModuleAgda-2.7.0.1Haskell2010
Agda.TypeChecking.MetaVars.Occurs
The occurs check for unification. Does pruning on the fly.
When hitting a meta variable:
Compute flex/rigid for its arguments.
Compare to allowed variables.
Mark arguments with rigid occurrences of disallowed variables for deletion.
Attempt to delete marked arguments.
We don't need to check for success, we can just continue occurs checking.
- 6 types
- 2 classes
- 30 values
- PackageAgda-2.7.0.1
- Exports38
- LanguageHaskell2010
- LicenceMIT
- SourceOccurs.hs
MetaOccursCheck: going into definitions to exclude cyclic solutions
4 declarationsSet the names of definitions to be looked at to the defs in the current mutual block.
Is a def in the list of stuff to be checked?
Remove a def from the list of defs to be looked at.
OccursM monad and its services
3 declarationsExtra environment for the occurs check. (Complements FreeEnv.)
Constructors
OccursExtraoccUnfold :: UnfoldStrategyoccVars :: VarMapThe allowed variables with their variance.
occMeta :: MetaIdThe meta we want to solve.
occCxtSize :: NatThe size of the typing context upon invocation.
Modality handling.
The passed modality is the one of the current context.
Check whether a free variable is allowed in the context as specified by the modality.
Occurs check fails if a defined name is not available since it was declared in irrelevant or erased context.
Construct a test whether a de Bruijn index is allowed or needs to be pruned.
Unfolding during occurs check.
Unfold definitions during occurs check? This effectively runs the occurs check on the normal form.
Instances2Eq, Show
Eq UnfoldStrategyDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursShow UnfoldStrategyDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.Occurs
For a path constructor `c : ... -> Path D a b`, we have that e.g. `c es i0` reduces to a.
So we have to consider its arguments as flexible when we do not actually unfold.
Managing rigidiy during occurs check.
Leave the strongly rigid position.
Error throwing during occurs check.
Implementation of the occurs check.
6 declarationsExtended occurs check.
Methods
occurs :: t -> OccursM tmetaOccurs :: MetaId -> t -> TCM ()
Instances13Occurs, …
Occurs QNameDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursOccurs ClauseDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursOccurs ElimsDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursOccurs LevelDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursOccurs PlusLevelDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursOccurs SortDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursOccurs TermDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursOccurs TypeDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursOccurs DefnDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursOccurs (Abs Term)Defined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursOccurs (Abs Type)Defined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursOccurs a => Occurs (Arg a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursOccurs a => Occurs (Dom a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.Occurs
When assigning m xs := v, check that m does not occur in v
and that the free variables of v are contained in xs.
Pruning: getting rid of flexible occurrences.
10 declarationsprune :: (PureTCM m, MonadMetaSolver m)=> MetaIdMeta to prune.
-> ArgsArguments to meta variable.
-> (Nat -> Bool)Test for allowed variable (de Bruijn index).
-> m PruneResult
prune m' vs xs attempts to remove all arguments from vs whose
free variables are not contained in xs.
If successful, m' is solved by the new, pruned meta variable and we
return True else False.
Issue 1147:
If any of the meta args vs is matchable, e.g., is a constructor term,
we cannot prune, because the offending variables could be removed by
reduction for a suitable instantiation of the meta variable.
hasBadRigid hasBadRigid xs v = Just True iff one of the rigid variables in v is not in xs.
Actually we can only prune if a bad variable is in the head. See issue 458.
Or in a non-eliminateable position (see succeed/PruningNonMillerPattern).
hasBadRigid xs v = Nothing means that
we cannot prune at all as one of the meta args is matchable.
(See issue 1147.)
Check whether a term Def f es is finally stuck.
Currently, we give only a crude approximation.
Check whether any of the variables (given as de Bruijn indices) occurs *definitely* in the term in a rigid position. Reduces the term successively to remove variables in dead subterms. This fixes issue 1386.
Collect the *definitely* rigid variables in a monoid. We need to successively reduce the expression to do this.
Instances11AnyRigid, …
AnyRigid LevelDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursAnyRigid PlusLevelDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursAnyRigid SortDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursAnyRigid TermDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursAnyRigid TypeDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursAnyRigid a => AnyRigid (Arg a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursAnyRigid a => AnyRigid (Dom a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursAnyRigid a => AnyRigid (Elim' a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursAnyRigid a => AnyRigid [a]Defined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.Occurs(Subst a, AnyRigid a) => AnyRigid (Abs a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.Occurs(AnyRigid a, AnyRigid b) => AnyRigid (a, b)Defined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.Occurs
Constructors
NothingToPrunethe kill list is empty or only
FalsesPrunedNothingthere is no possible kill (because of type dep.)
PrunedSomethingmanaged to kill some args in the list
PrunedEverythingall prescribed kills where performed
Instances2Eq, Show
Eq PruneResultDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.OccursShow PruneResultDefined in Agda-2.7.0.1 · Agda.TypeChecking.MetaVars.Occurs
killArgs [k1,...,kn] X prunes argument i from metavar X if ki==True.
Pruning is carried out whenever > 0 arguments can be pruned.
killedType [((x1,a1),k1)..((xn,an),kn)] b = ([k'1..k'n],t')
(ignoring Dom). Let t' = (xs:as) -> b.
Invariant: k'i == True iff ki == True and pruning the ith argument from
type b is possible without creating unbound variables.
t' is type t after pruning all k'i==True.
performKill :: MonadMetaSolver m=> [Arg Bool]Arguments to old meta var in left to right order with
Boolindicating whether they can be pruned.-> MetaIdThe old meta var to receive pruning.
-> TypeThe pruned type of the new meta var.
-> m ()
Instantiate a meta variable with a new one that only takes the arguments which are not pruneable.