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

Safe HaskellNone
LanguageHaskell2010

Agda.TypeChecking.Substitute

Contents

Description

This module contains the definition of hereditary substitution and application operating on internal syntax which is in β-normal form (β including projection reductions).

Further, it contains auxiliary functions which rely on substitution but not on reduction.

Synopsis

Documentation

class TeleNoAbs a where #

Performs void (noAbs) abstraction over telescope.

Minimal complete definition

teleNoAbs

Methods

teleNoAbs :: a -> Term -> Term #

Instances
TeleNoAbs ListTel # 
Instance details

Defined in Agda.TypeChecking.Substitute

Methods

teleNoAbs :: ListTel -> Term -> Term #

TeleNoAbs Telescope # 
Instance details

Defined in Agda.TypeChecking.Substitute

Methods

teleNoAbs :: Telescope -> Term -> Term #

data TelV a #

Constructors

TelV 

Fields

Instances
Functor TelV # 
Instance details

Defined in Agda.TypeChecking.Substitute

Methods

fmap :: (a -> b) -> TelV a -> TelV b #

(<$) :: a -> TelV b -> TelV a #

(Subst t a, Eq a) => Eq (TelV a) # 
Instance details

Defined in Agda.TypeChecking.Substitute

Methods

(==) :: TelV a -> TelV a -> Bool #

(/=) :: TelV a -> TelV a -> Bool #

(Subst t a, Ord a) => Ord (TelV a) # 
Instance details

Defined in Agda.TypeChecking.Substitute

Methods

compare :: TelV a -> TelV a -> Ordering #

(<) :: TelV a -> TelV a -> Bool #

(<=) :: TelV a -> TelV a -> Bool #

(>) :: TelV a -> TelV a -> Bool #

(>=) :: TelV a -> TelV a -> Bool #

max :: TelV a -> TelV a -> TelV a #

min :: TelV a -> TelV a -> TelV a #

Show a => Show (TelV a) # 
Instance details

Defined in Agda.TypeChecking.Substitute

Methods

showsPrec :: Int -> TelV a -> ShowS #

show :: TelV a -> String #

showList :: [TelV a] -> ShowS #

canProject :: QName -> Term -> Maybe (Arg Term) #

If $v$ is a record value, canProject f v returns its field f.

conApp :: ConHead -> ConInfo -> Elims -> Elims -> Term #

Eliminate a constructed term.

defApp :: QName -> Elims -> Elims -> Term #

defApp f us vs applies Def f us to further arguments vs, eliminating top projection redexes. If us is not empty, we cannot have a projection redex, since the record argument is the first one.

piApply :: Type -> Args -> Type #

(x:A)->B(x) piApply [u] = B(u)

Precondition: The type must contain the right number of pis without having to perform any reduction.

piApply is potentially unsafe, the monadic piApplyM is preferable.

abstractArgs :: Abstract a => Args -> a -> a #

renaming :: forall a. DeBruijn a => Empty -> Permutation -> Substitution' a #

If permute π : [a]Γ -> [a]Δ, then applySubst (renaming _ π) : Term Γ -> Term Δ

renamingR :: DeBruijn a => Permutation -> Substitution' a #

If permute π : [a]Γ -> [a]Δ, then applySubst (renamingR π) : Term Δ -> Term Γ

renameP :: Subst t a => Empty -> Permutation -> a -> a #

The permutation should permute the corresponding context. (right-to-left list)

projDropParsApply :: Projection -> ProjOrigin -> Args -> Term #

projDropParsApply proj o args = projDropPars proj o `apply' args

This function is an optimization, saving us from construction lambdas we immediately remove through application.

telView' :: Type -> TelView #

Takes off all exposed function domains from the given type. This means that it does not reduce to expose Pi-types.

telView'UpTo :: Int -> Type -> TelView #

telView'UpTo n t takes off the first n exposed function types of t. Takes off all (exposed ones) if n < 0.

bindsToTel' :: (Name -> a) -> [Name] -> Dom Type -> ListTel' a #

Turn a typed binding (x1 .. xn : A) into a telescope.

bindsWithHidingToTel' :: (Name -> a) -> [WithHiding Name] -> Dom Type -> ListTel' a #

Turn a typed binding (x1 .. xn : A) into a telescope.

mkPi :: Dom (ArgName, Type) -> Type -> Type #

mkPi dom t = telePi (telFromList [dom]) t

telePi :: Telescope -> Type -> Type #

Uses free variable analysis to introduce NoAbs bindings.

telePi_ :: Telescope -> Type -> Type #

Everything will be an Abs.

teleLam :: Telescope -> Term -> Term #

Abstract over a telescope in a term, producing lambdas. Dumb abstraction: Always produces Abs, never NoAbs.

The implementation is sound because Telescope does not use NoAbs.

typeArgsWithTel :: Telescope -> [Term] -> Maybe [Dom Type] #

Given arguments vs : tel (vector typing), extract their individual types. Returns Nothing is tel is not long enough.

compiledClauseBody :: Clause -> Maybe Term #

In compiled clauses, the variables in the clause body are relative to the pattern variables (including dot patterns) instead of the clause telescope.

univSort' :: Sort -> Maybe Sort #

Get the next higher sort.

funSort' :: Sort -> Sort -> Maybe Sort #

Compute the sort of a function type from the sorts of its domain and codomain.

piSort' :: Sort -> Abs Sort -> Maybe Sort #

Compute the sort of a pi type from the sorts of its domain and codomain.

data Substitution' a #

Substitutions.

Constructors

IdS

Identity substitution. Γ ⊢ IdS : Γ

EmptyS Empty

Empty substitution, lifts from the empty context. First argument is IMPOSSIBLE. Apply this to closed terms you want to use in a non-empty context. Γ ⊢ EmptyS : ()

a :# (Substitution' a) infixr 4

Substitution extension, `cons'. Γ ⊢ u : Aρ Γ ⊢ ρ : Δ ---------------------- Γ ⊢ u :# ρ : Δ, A

Strengthen Empty (Substitution' a)

Strengthening substitution. First argument is IMPOSSIBLE. Apply this to a term which does not contain variable 0 to lower all de Bruijn indices by one. Γ ⊢ ρ : Δ --------------------------- Γ ⊢ Strengthen ρ : Δ, A

Wk !Int (Substitution' a)

Weakning substitution, lifts to an extended context. Γ ⊢ ρ : Δ ------------------- Γ, Ψ ⊢ Wk |Ψ| ρ : Δ

Lift !Int (Substitution' a)

Lifting substitution. Use this to go under a binder. Lift 1 ρ == var 0 :# Wk 1 ρ. Γ ⊢ ρ : Δ ------------------------- Γ, Ψρ ⊢ Lift |Ψ| ρ : Δ, Ψ

Instances
Functor Substitution' # 
Instance details

Defined in Agda.Syntax.Internal

Methods

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

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

Foldable Substitution' # 
Instance details

Defined in Agda.Syntax.Internal

Methods

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

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

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

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

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

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

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

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

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

null :: Substitution' a -> Bool #

length :: Substitution' a -> Int #

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

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

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

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

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

Traversable Substitution' # 
Instance details

Defined in Agda.Syntax.Internal

Methods

traverse :: Applicative f => (a -> f b) -> Substitution' a -> f (Substitution' b) #

sequenceA :: Applicative f => Substitution' (f a) -> f (Substitution' a) #

mapM :: Monad m => (a -> m b) -> Substitution' a -> m (Substitution' b) #

sequence :: Monad m => Substitution' (m a) -> m (Substitution' a) #

KillRange Substitution # 
Instance details

Defined in Agda.Syntax.Internal

InstantiateFull Substitution # 
Instance details

Defined in Agda.TypeChecking.Reduce

Subst a a => Subst a (Substitution' a) # 
Instance details

Defined in Agda.TypeChecking.Substitute

Eq (Substitution' Term) # 
Instance details

Defined in Agda.TypeChecking.Substitute

Data a => Data (Substitution' a) # 
Instance details

Defined in Agda.Syntax.Internal

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Substitution' a -> c (Substitution' a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Substitution' a) #

toConstr :: Substitution' a -> Constr #

dataTypeOf :: Substitution' a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Substitution' a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Substitution' a)) #

gmapT :: (forall b. Data b => b -> b) -> Substitution' a -> Substitution' a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Substitution' a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Substitution' a -> r #

gmapQ :: (forall d. Data d => d -> u) -> Substitution' a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Substitution' a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Substitution' a -> m (Substitution' a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Substitution' a -> m (Substitution' a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Substitution' a -> m (Substitution' a) #

Ord (Substitution' Term) # 
Instance details

Defined in Agda.TypeChecking.Substitute

Show a => Show (Substitution' a) # 
Instance details

Defined in Agda.Syntax.Internal

Null (Substitution' a) # 
Instance details

Defined in Agda.Syntax.Internal

Pretty a => Pretty (Substitution' a) # 
Instance details

Defined in Agda.Syntax.Internal

TermSize a => TermSize (Substitution' a) # 
Instance details

Defined in Agda.Syntax.Internal

EmbPrj a => EmbPrj (Substitution' a) # 
Instance details

Defined in Agda.TypeChecking.Serialise.Instances.Internal

(Pretty a, PrettyTCM a, Subst a a) => PrettyTCM (Substitution' a) # 
Instance details

Defined in Agda.TypeChecking.Pretty

Orphan instances

Eq NotBlocked # 
Instance details

Eq LevelAtom # 
Instance details

Eq PlusLevel # 
Instance details

Eq Level # 
Instance details

Methods

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

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

Eq Sort # 
Instance details

Methods

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

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

Eq Term #

Syntactic Term equality, ignores stuff below DontCare and sharing.

Instance details

Methods

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

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

Eq Candidate # 
Instance details

Eq Section # 
Instance details

Methods

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

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

Eq Constraint # 
Instance details

Ord LevelAtom # 
Instance details

Ord PlusLevel # 
Instance details

Ord Level # 
Instance details

Methods

compare :: Level -> Level -> Ordering #

(<) :: Level -> Level -> Bool #

(<=) :: Level -> Level -> Bool #

(>) :: Level -> Level -> Bool #

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

max :: Level -> Level -> Level #

min :: Level -> Level -> Level #

Ord Sort # 
Instance details

Methods

compare :: Sort -> Sort -> Ordering #

(<) :: Sort -> Sort -> Bool #

(<=) :: Sort -> Sort -> Bool #

(>) :: Sort -> Sort -> Bool #

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

max :: Sort -> Sort -> Sort #

min :: Sort -> Sort -> Sort #

Ord Term # 
Instance details

Methods

compare :: Term -> Term -> Ordering #

(<) :: Term -> Term -> Bool #

(<=) :: Term -> Term -> Bool #

(>) :: Term -> Term -> Bool #

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

max :: Term -> Term -> Term #

min :: Term -> Term -> Term #

DeBruijn DeBruijnPattern # 
Instance details

DeBruijn NLPat # 
Instance details

Abstract Permutation # 
Instance details

Abstract Clause # 
Instance details

Methods

abstract :: Telescope -> Clause -> Clause #

Abstract Sort # 
Instance details

Methods

abstract :: Telescope -> Sort -> Sort #

Abstract Telescope # 
Instance details

Abstract Type # 
Instance details

Methods

abstract :: Telescope -> Type -> Type #

Abstract Term # 
Instance details

Methods

abstract :: Telescope -> Term -> Term #

Abstract CompiledClauses # 
Instance details

Abstract FunctionInverse # 
Instance details

Abstract PrimFun # 
Instance details

Abstract Defn # 
Instance details

Methods

abstract :: Telescope -> Defn -> Defn #

Abstract ProjLams # 
Instance details

Abstract Projection # 
Instance details

Abstract Definition # 
Instance details

Abstract RewriteRule #

tel ⊢ (Γ ⊢ lhs ↦ rhs : t) becomes tel, Γ ⊢ lhs ↦ rhs : t) we do not need to change lhs, rhs, and t since they live in Γ. See 'Abstract Clause'.

Instance details

Apply Permutation # 
Instance details

Apply Clause # 
Instance details

Methods

apply :: Clause -> Args -> Clause #

applyE :: Clause -> Elims -> Clause #

Apply Sort # 
Instance details

Methods

apply :: Sort -> Args -> Sort #

applyE :: Sort -> Elims -> Sort #

Apply Term # 
Instance details

Methods

apply :: Term -> Args -> Term #

applyE :: Term -> Elims -> Term #

Apply CompiledClauses # 
Instance details

Apply FunctionInverse # 
Instance details

Apply PrimFun # 
Instance details

Apply Defn # 
Instance details

Methods

apply :: Defn -> Args -> Defn #

applyE :: Defn -> Elims -> Defn #

Apply ProjLams # 
Instance details

Apply Projection # 
Instance details

Apply Definition # 
Instance details

Apply RewriteRule # 
Instance details

Apply DisplayTerm # 
Instance details

Subst DeBruijnPattern DeBruijnPattern # 
Instance details

Subst Term () # 
Instance details

Methods

applySubst :: Substitution' Term -> () -> () #

Subst Term String # 
Instance details

Subst Term Range # 
Instance details

Subst Term Name # 
Instance details

Subst Term EqualityView # 
Instance details

Subst Term ConPatternInfo # 
Instance details

Subst Term Pattern # 
Instance details

Subst Term LevelAtom # 
Instance details

Subst Term PlusLevel # 
Instance details

Subst Term Level # 
Instance details

Subst Term Sort # 
Instance details

Subst Term Term # 
Instance details

Subst Term ProblemEq # 
Instance details

Subst Term Candidate # 
Instance details

Subst Term DisplayTerm # 
Instance details

Subst Term DisplayForm # 
Instance details

Subst Term Constraint # 
Instance details

Subst NLPat RewriteRule # 
Instance details

Subst NLPat NLPType # 
Instance details

Subst NLPat NLPat # 
Instance details

Subst t a => Subst t [a] # 
Instance details

Methods

applySubst :: Substitution' t -> [a] -> [a] #

Subst t a => Subst t (Maybe a) # 
Instance details

Methods

applySubst :: Substitution' t -> Maybe a -> Maybe a #

Subst t a => Subst t (Dom a) # 
Instance details

Methods

applySubst :: Substitution' t -> Dom a -> Dom a #

Subst t a => Subst t (Arg a) # 
Instance details

Methods

applySubst :: Substitution' t -> Arg a -> Arg a #

Subst t a => Subst t (Abs a) # 
Instance details

Methods

applySubst :: Substitution' t -> Abs a -> Abs a #

Subst t a => Subst t (Elim' a) # 
Instance details

Methods

applySubst :: Substitution' t -> Elim' a -> Elim' a #

Subst t a => Subst t (Tele a) # 
Instance details

Methods

applySubst :: Substitution' t -> Tele a -> Tele a #

Subst t a => Subst t (Blocked a) # 
Instance details

Methods

applySubst :: Substitution' t -> Blocked a -> Blocked a #

Subst a a => Subst a (Substitution' a) # 
Instance details

Subst Term a => Subst Term (Type' a) # 
Instance details

(Subst t a, Subst t b) => Subst t (a, b) # 
Instance details

Methods

applySubst :: Substitution' t -> (a, b) -> (a, b) #

(Ord k, Subst t a) => Subst t (Map k a) # 
Instance details

Methods

applySubst :: Substitution' t -> Map k a -> Map k a #

Subst t a => Subst t (Named name a) # 
Instance details

Methods

applySubst :: Substitution' t -> Named name a -> Named name a #

(Subst t a, Subst t b, Subst t c) => Subst t (a, b, c) # 
Instance details

Methods

applySubst :: Substitution' t -> (a, b, c) -> (a, b, c) #

(Subst t a, Subst t b, Subst t c, Subst t d) => Subst t (a, b, c, d) # 
Instance details

Methods

applySubst :: Substitution' t -> (a, b, c, d) -> (a, b, c, d) #

Eq (Substitution' Term) # 
Instance details

Eq t => Eq (Blocked t) # 
Instance details

Methods

(==) :: Blocked t -> Blocked t -> Bool #

(/=) :: Blocked t -> Blocked t -> Bool #

(Subst t a, Eq a) => Eq (Tele a) # 
Instance details

Methods

(==) :: Tele a -> Tele a -> Bool #

(/=) :: Tele a -> Tele a -> Bool #

Eq a => Eq (Type' a) #

Syntactic Type equality, ignores sort annotations.

Instance details

Methods

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

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

(Subst t a, Eq a) => Eq (Abs a) #

Equality of binders relies on weakening which is a special case of renaming which is a special case of substitution.

Instance details

Methods

(==) :: Abs a -> Abs a -> Bool #

(/=) :: Abs a -> Abs a -> Bool #

(Subst t a, Eq a) => Eq (Elim' a) # 
Instance details

Methods

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

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

Ord (Substitution' Term) # 
Instance details

(Subst t a, Ord a) => Ord (Tele a) # 
Instance details

Methods

compare :: Tele a -> Tele a -> Ordering #

(<) :: Tele a -> Tele a -> Bool #

(<=) :: Tele a -> Tele a -> Bool #

(>) :: Tele a -> Tele a -> Bool #

(>=) :: Tele a -> Tele a -> Bool #

max :: Tele a -> Tele a -> Tele a #

min :: Tele a -> Tele a -> Tele a #

Ord a => Ord (Type' a) # 
Instance details

Methods

compare :: Type' a -> Type' a -> Ordering #

(<) :: Type' a -> Type' a -> Bool #

(<=) :: Type' a -> Type' a -> Bool #

(>) :: Type' a -> Type' a -> Bool #

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

max :: Type' a -> Type' a -> Type' a #

min :: Type' a -> Type' a -> Type' a #

(Subst t a, Ord a) => Ord (Abs a) # 
Instance details

Methods

compare :: Abs a -> Abs a -> Ordering #

(<) :: Abs a -> Abs a -> Bool #

(<=) :: Abs a -> Abs a -> Bool #

(>) :: Abs a -> Abs a -> Bool #

(>=) :: Abs a -> Abs a -> Bool #

max :: Abs a -> Abs a -> Abs a #

min :: Abs a -> Abs a -> Abs a #

(Subst t a, Ord a) => Ord (Elim' a) # 
Instance details

Methods

compare :: Elim' a -> Elim' a -> Ordering #

(<) :: Elim' a -> Elim' a -> Bool #

(<=) :: Elim' a -> Elim' a -> Bool #

(>) :: Elim' a -> Elim' a -> Bool #

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

max :: Elim' a -> Elim' a -> Elim' a #

min :: Elim' a -> Elim' a -> Elim' a #

Abstract t => Abstract [t] # 
Instance details

Methods

abstract :: Telescope -> [t] -> [t] #

Abstract [Occurrence] # 
Instance details

Abstract [Polarity] # 
Instance details

Methods

abstract :: Telescope -> [Polarity] -> [Polarity] #

Abstract t => Abstract (Maybe t) # 
Instance details

Methods

abstract :: Telescope -> Maybe t -> Maybe t #

DoDrop a => Abstract (Drop a) # 
Instance details

Methods

abstract :: Telescope -> Drop a -> Drop a #

Abstract a => Abstract (Case a) # 
Instance details

Methods

abstract :: Telescope -> Case a -> Case a #

Abstract a => Abstract (WithArity a) # 
Instance details

Methods

abstract :: Telescope -> WithArity a -> WithArity a #

Apply t => Apply [t] # 
Instance details

Methods

apply :: [t] -> Args -> [t] #

applyE :: [t] -> Elims -> [t] #

Apply [NamedArg (Pattern' a)] #

Make sure we only drop variable patterns.

Instance details

Methods

apply :: [NamedArg (Pattern' a)] -> Args -> [NamedArg (Pattern' a)] #

applyE :: [NamedArg (Pattern' a)] -> Elims -> [NamedArg (Pattern' a)] #

Apply [Occurrence] # 
Instance details

Apply [Polarity] # 
Instance details

Methods

apply :: [Polarity] -> Args -> [Polarity] #

applyE :: [Polarity] -> Elims -> [Polarity] #

Apply t => Apply (Maybe t) # 
Instance details

Methods

apply :: Maybe t -> Args -> Maybe t #

applyE :: Maybe t -> Elims -> Maybe t #

DoDrop a => Apply (Drop a) # 
Instance details

Methods

apply :: Drop a -> Args -> Drop a #

applyE :: Drop a -> Elims -> Drop a #

Apply t => Apply (Blocked t) # 
Instance details

Methods

apply :: Blocked t -> Args -> Blocked t #

applyE :: Blocked t -> Elims -> Blocked t #

Subst Term a => Apply (Tele a) # 
Instance details

Methods

apply :: Tele a -> Args -> Tele a #

applyE :: Tele a -> Elims -> Tele a #

Apply a => Apply (Case a) # 
Instance details

Methods

apply :: Case a -> Args -> Case a #

applyE :: Case a -> Elims -> Case a #

Apply a => Apply (WithArity a) # 
Instance details

Methods

apply :: WithArity a -> Args -> WithArity a #

applyE :: WithArity a -> Elims -> WithArity a #

Abstract v => Abstract (Map k v) # 
Instance details

Methods

abstract :: Telescope -> Map k v -> Map k v #

Abstract v => Abstract (HashMap k v) # 
Instance details

Methods

abstract :: Telescope -> HashMap k v -> HashMap k v #

(Apply a, Apply b) => Apply (a, b) # 
Instance details

Methods

apply :: (a, b) -> Args -> (a, b) #

applyE :: (a, b) -> Elims -> (a, b) #

Apply v => Apply (Map k v) # 
Instance details

Methods

apply :: Map k v -> Args -> Map k v #

applyE :: Map k v -> Elims -> Map k v #

Apply v => Apply (HashMap k v) # 
Instance details

Methods

apply :: HashMap k v -> Args -> HashMap k v #

applyE :: HashMap k v -> Elims -> HashMap k v #

(Apply a, Apply b, Apply c) => Apply (a, b, c) # 
Instance details

Methods

apply :: (a, b, c) -> Args -> (a, b, c) #

applyE :: (a, b, c) -> Elims -> (a, b, c) #