Agda
Safe HaskellNone
LanguageHaskell2010

Agda.TypeChecking.Free.Base

Synopsis

Set of meta variables.

newtype MetaSet Source #

A set of meta variables. Forms a monoid under union.

Constructors

MetaSet 

Instances

Instances details
Pretty MetaSet Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

PrettyTCM MetaSet Source # 
Instance details

Defined in Agda.TypeChecking.Pretty

Methods

prettyTCM :: MonadPretty m => MetaSet -> m Doc Source #

Null MetaSet Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Monoid MetaSet Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Semigroup MetaSet Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Show MetaSet Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Eq MetaSet Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Methods

(==) :: MetaSet -> MetaSet -> Bool #

(/=) :: MetaSet -> MetaSet -> Bool #

Singleton MetaId MetaSet Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

foldrMetaSet :: (MetaId -> a -> a) -> a -> MetaSet -> a Source #

Flexible and rigid occurrences (semigroup)

data FlexRig' a Source #

Depending on the surrounding context of a variable, it's occurrence can be classified as flexible or rigid, with finer distinctions.

The constructors are listed in increasing order (wrt. information content).

Constructors

Flexible !a

In arguments of metas. The set of metas is used by 'NonLinMatch' to generate the right blocking information. The semantics is that the status of a variable occurrence may change if one of the metas in the set gets solved. We may say the occurrence is tainted by the meta variables in the set.

WeaklyRigid

In arguments to variables and definitions.

Unguarded

In top position, or only under inductive record constructors (unit).

StronglyRigid

Under at least one and only inductive constructors.

Instances

Instances details
Functor FlexRig' Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Methods

fmap :: (a -> b) -> FlexRig' a -> FlexRig' b #

(<$) :: a -> FlexRig' b -> FlexRig' a #

Foldable FlexRig' Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Methods

fold :: Monoid m => FlexRig' m -> m #

foldMap :: Monoid m => (a -> m) -> FlexRig' a -> m #

foldMap' :: Monoid m => (a -> m) -> FlexRig' a -> m #

foldr :: (a -> b -> b) -> b -> FlexRig' a -> b #

foldr' :: (a -> b -> b) -> b -> FlexRig' a -> b #

foldl :: (b -> a -> b) -> b -> FlexRig' a -> b #

foldl' :: (b -> a -> b) -> b -> FlexRig' a -> b #

foldr1 :: (a -> a -> a) -> FlexRig' a -> a #

foldl1 :: (a -> a -> a) -> FlexRig' a -> a #

toList :: FlexRig' a -> [a] #

null :: FlexRig' a -> Bool #

length :: FlexRig' a -> Int #

elem :: Eq a => a -> FlexRig' a -> Bool #

maximum :: Ord a => FlexRig' a -> a #

minimum :: Ord a => FlexRig' a -> a #

sum :: Num a => FlexRig' a -> a #

product :: Num a => FlexRig' a -> a #

Pretty a => Pretty (FlexRig' a) Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

PrettyTCM a => PrettyTCM (FlexRig' a) Source # 
Instance details

Defined in Agda.TypeChecking.Pretty

Methods

prettyTCM :: MonadPretty m => FlexRig' a -> m Doc Source #

Show a => Show (FlexRig' a) Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Methods

showsPrec :: Int -> FlexRig' a -> ShowS #

show :: FlexRig' a -> String #

showList :: [FlexRig' a] -> ShowS #

Eq a => Eq (FlexRig' a) Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Methods

(==) :: FlexRig' a -> FlexRig' a -> Bool #

(/=) :: FlexRig' a -> FlexRig' a -> Bool #

LensFlexRig (FlexRig' a) a Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Singleton (Variable, FlexRig' ()) FlexRigMap Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

class LensFlexRig o a | o -> a where Source #

Instances

Instances details
LensFlexRig (FlexRig' a) a Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

LensFlexRig (VarOcc' a) a Source #

Access to varFlexRig in VarOcc.

Instance details

Defined in Agda.TypeChecking.Free.Base

LensFlexRig (FreeEnv' a b c) a Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Methods

lensFlexRig :: Lens' (FreeEnv' a b c) (FlexRig' a) Source #

addFlexRig :: Semigroup a => FlexRig' a -> FlexRig' a -> FlexRig' a Source #

FlexRig aggregation (additive operation of the semiring). For combining occurrences of the same variable in subterms. This is a refinement of the max operation for FlexRig which would work if Flexible did not have the MetaSet as an argument. Now, to aggregate two Flexible occurrences, we union the involved MetaSets.

composeFlexRig :: Semigroup a => FlexRig' a -> FlexRig' a -> FlexRig' a Source #

FlexRig composition (multiplicative operation of the semiring). For accumulating the context of a variable.

Flexible is dominant. Once we are under a meta, we are flexible regardless what else comes. We taint all variable occurrences under a meta by this meta.

WeaklyRigid is next in strength. Destroys strong rigidity.

StronglyRigid is still dominant over Unguarded.

Unguarded is the unit. It is the top (identity) context.

flexRigToBlocker :: FlexRig -> Blocker Source #

Extract a blocker from an occurrence

Multi-dimensional feature vector for variable occurrence (semigroup)

data VarOcc' a Source #

Occurrence of free variables is classified by several dimensions. Currently, we have FlexRig and Modality.

Constructors

VarOcc 

Instances

Instances details
LensModality (VarOcc' a) Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

LensQuantity (VarOcc' a) Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

LensRelevance (VarOcc' a) Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Pretty a => Pretty (VarOcc' a) Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

PrettyTCM a => PrettyTCM (VarOcc' a) Source # 
Instance details

Defined in Agda.TypeChecking.Pretty

Methods

prettyTCM :: MonadPretty m => VarOcc' a -> m Doc Source #

Monoid a => Monoid (VarOcc' a) Source #

The neutral element for variable occurrence aggregation is least serious occurrence: flexible, irrelevant. This is also the absorptive element for composeVarOcc, if we ignore the MetaSet in Flexible.

Instance details

Defined in Agda.TypeChecking.Free.Base

Methods

mempty :: VarOcc' a #

mappend :: VarOcc' a -> VarOcc' a -> VarOcc' a #

mconcat :: [VarOcc' a] -> VarOcc' a #

Semigroup a => Semigroup (VarOcc' a) Source #

The default way of aggregating free variable info from subterms is by adding the variable occurrences. For instance, if we have a pair (t₁,t₂) then and t₁ has o₁ the occurrences of a variable x and t₂ has o₂ the occurrences of the same variable, then (t₁,t₂) has mappend o₁ o₂ occurrences of that variable.

From counting Quantity, we extrapolate this to FlexRig and Relevance: we care most about about StronglyRigid Relevant occurrences. E.g., if t₁ has a StronglyRigid occurrence and t₂ a Flexible occurrence, then (t₁,t₂) still has a StronglyRigid occurrence. Analogously, Relevant occurrences count most, as we wish e.g. to forbid relevant occurrences of variables that are declared to be irrelevant.

VarOcc forms a semiring, and this monoid is the addition of the semiring.

Instance details

Defined in Agda.TypeChecking.Free.Base

Methods

(<>) :: VarOcc' a -> VarOcc' a -> VarOcc' a #

sconcat :: NonEmpty (VarOcc' a) -> VarOcc' a #

stimes :: Integral b => b -> VarOcc' a -> VarOcc' a #

Show a => Show (VarOcc' a) Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Methods

showsPrec :: Int -> VarOcc' a -> ShowS #

show :: VarOcc' a -> String #

showList :: [VarOcc' a] -> ShowS #

Eq a => Eq (VarOcc' a) Source #

Equality up to origin.

Instance details

Defined in Agda.TypeChecking.Free.Base

Methods

(==) :: VarOcc' a -> VarOcc' a -> Bool #

(/=) :: VarOcc' a -> VarOcc' a -> Bool #

LensFlexRig (VarOcc' a) a Source #

Access to varFlexRig in VarOcc.

Instance details

Defined in Agda.TypeChecking.Free.Base

topVarOcc :: VarOcc' a Source #

The absorptive element of variable occurrence under aggregation: strongly rigid, relevant.

composeVarOcc :: Semigroup a => VarOcc' a -> VarOcc' a -> VarOcc' a Source #

First argument is the outer occurrence (context) and second is the inner. This multiplicative operation is to modify an occurrence under a context.

constructorFlexRig :: ConHead -> Elims -> FlexRig' a Source #

What's the rigidity of a constructor?

Storing variable occurrences (semimodule).

class (Singleton MetaId a, Monoid a, Monoid c) => IsVarSet a c | c -> a where Source #

Any representation c of a set of variables need to be able to be modified by a variable occurrence. This is to ensure that free variable analysis is compositional. For instance, it should be possible to compute `fv (v [u/x])` from `fv v` and `fv u`.

In algebraic terminology, a variable set a needs to be (almost) a left semimodule to the semiring VarOcc.

Methods

withVarOcc :: VarOcc' a -> c -> c Source #

Laws * Respects monoid operations: ``` withVarOcc o mempty == mempty withVarOcc o (x <> y) == withVarOcc o x <> withVarOcc o y ``` * Respects VarOcc composition: ``` withVarOcc oneVarOcc = id withVarOcc (composeVarOcc o1 o2) = withVarOcc o1 . withVarOcc o2 ``` * Respects VarOcc aggregation: ``` withVarOcc (o1 <> o2) x = withVarOcc o1 x <> withVarOcc o2 x ``` Since the corresponding unit law may fail, ``` withVarOcc mempty x = mempty ``` it is not quite a semimodule.

Instances

Instances details
IsVarSet () FlexRigMap Source #

Compose everything with the varFlexRig part of the VarOcc.

Instance details

Defined in Agda.TypeChecking.Free.Base

IsVarSet () VarCounts Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

IsVarSet () AllowedVar Source # 
Instance details

Defined in Agda.TypeChecking.MetaVars.Occurs

(Singleton MetaId a, Monoid a) => IsVarSet a (VarMap' a) Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Methods

withVarOcc :: VarOcc' a -> VarMap' a -> VarMap' a Source #

type TheVarMap' a = IntMap (VarOcc' a) Source #

Representation of a variable set as map from de Bruijn indices to VarOcc.

newtype VarMap' a Source #

Constructors

VarMap 

Fields

Instances

Instances details
(Singleton MetaId a, Monoid a) => IsVarSet a (VarMap' a) Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Methods

withVarOcc :: VarOcc' a -> VarMap' a -> VarMap' a Source #

Singleton Variable (VarMap' a) Source #

A "set"-style Singleton instance with default/initial variable occurrence.

Instance details

Defined in Agda.TypeChecking.Free.Base

PrettyTCM a => PrettyTCM (VarMap' a) Source # 
Instance details

Defined in Agda.TypeChecking.Pretty

Methods

prettyTCM :: MonadPretty m => VarMap' a -> m Doc Source #

Semigroup a => Monoid (VarMap' a) Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Methods

mempty :: VarMap' a #

mappend :: VarMap' a -> VarMap' a -> VarMap' a #

mconcat :: [VarMap' a] -> VarMap' a #

Semigroup a => Semigroup (VarMap' a) Source #

Proper monoid instance for VarMap rather than inheriting the broken one from IntMap. We combine two occurrences of a variable using mappend.

Instance details

Defined in Agda.TypeChecking.Free.Base

Methods

(<>) :: VarMap' a -> VarMap' a -> VarMap' a #

sconcat :: NonEmpty (VarMap' a) -> VarMap' a #

stimes :: Integral b => b -> VarMap' a -> VarMap' a #

Show a => Show (VarMap' a) Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Methods

showsPrec :: Int -> VarMap' a -> ShowS #

show :: VarMap' a -> String #

showList :: [VarMap' a] -> ShowS #

Eq a => Eq (VarMap' a) Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Methods

(==) :: VarMap' a -> VarMap' a -> Bool #

(/=) :: VarMap' a -> VarMap' a -> Bool #

Simple flexible/rigid variable collection.

type TheFlexRigMap = IntMap (FlexRig' ()) Source #

Keep track of FlexRig for every variable, but forget the involved meta vars.

Plain variable occurrence counting.

Environment for collecting free variables.

data IgnoreSorts Source #

Where should we skip sorts in free variable analysis?

Constructors

IgnoreNot

Do not skip.

IgnoreInAnnotations

Skip when annotation to a type.

IgnoreAll

Skip unconditionally.

Instances

Instances details
Show IgnoreSorts Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Eq IgnoreSorts Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

data FreeEnv' a b c Source #

The current context.

Constructors

FreeEnv 

Fields

Instances

Instances details
LensModality (FreeEnv' a b c) Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

LensQuantity (FreeEnv' a b c) Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

LensRelevance (FreeEnv' a b c) Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

LensFlexRig (FreeEnv' a b c) a Source # 
Instance details

Defined in Agda.TypeChecking.Free.Base

Methods

lensFlexRig :: Lens' (FreeEnv' a b c) (FlexRig' a) Source #

type SingleVar c = Variable -> c Source #

feIgnoreSorts :: FreeEnv' a IgnoreSorts c -> IgnoreSorts Source #

Ignore free variables in sorts.

initFreeEnv :: Monoid c => b -> SingleVar c -> FreeEnv' a b c Source #

The initial context.

Orphan instances

Singleton MetaId () Source # 
Instance details

Methods

singleton :: MetaId -> () Source #