Agda-2.4.2.1: A dependently typed functional programming language and proof assistant

Safe HaskellNone
LanguageHaskell98

Agda.TypeChecking.MetaVars.Occurs

Contents

Synopsis

Documentation

initOccursCheck :: MetaVariable -> TCM () Source

Set the names of definitions to be looked at to the defs in the current mutual block.

defNeedsChecking :: QName -> TCM Bool Source

Is a def in the list of stuff to be checked?

tallyDef :: QName -> TCM () Source

Remove a def from the list of defs to be looked at.

data OccursCtx Source

Constructors

Flex

we are in arguments of a meta

Rigid

we are not in arguments of a meta but a bound var

StronglyRigid

we are at the start or in the arguments of a constructor

Top

we are at the term root (this turns into StronglyRigid)

Irrel

we are in an irrelevant argument

leaveTop :: OccursCtx -> OccursCtx Source

Leave the top position.

weakly :: OccursCtx -> OccursCtx Source

Leave the strongly rigid position.

type Vars = ([Nat], [Nat]) Source

Distinguish relevant and irrelevant variables in occurs check.

class Occurs t where Source

Extended occurs check.

Methods

occurs :: UnfoldStrategy -> OccursCtx -> MetaId -> Vars -> t -> TCM t Source

metaOccurs :: MetaId -> t -> TCM () Source

occursCheck :: MetaId -> Vars -> Term -> TCM Term Source

When assigning m xs := v, check that m does not occur in v and that the free variables of v are contained in xs.

Getting rid of flexible occurrences

prune :: MetaId -> Args -> [Nat] -> TCM PruneResult Source

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 :: [Nat] -> Term -> ExceptT () TCM Bool Source

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.)

isNeutral :: MonadTCM tcm => QName -> Elims -> tcm Bool Source

Check whether a term Def f es is finally stuck. Currently, we give only a crude approximation.

data PruneResult Source

Constructors

NothingToPrune

the kill list is empty or only Falses

PrunedNothing

there is no possible kill (because of type dep.)

PrunedSomething

managed to kill some args in the list

PrunedEverything

all prescribed kills where performed

killArgs :: [Bool] -> MetaId -> TCM PruneResult Source

killArgs [k1,...,kn] X prunes argument i from metavar X if ki==True. Pruning is carried out whenever > 0 arguments can be pruned. True is only returned if all arguments could be pruned.

killedType :: [(Dom (ArgName, Type), Bool)] -> Type -> ([Arg Bool], Type) Source

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.