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

Safe HaskellNone
LanguageHaskell98

Agda.TypeChecking.Substitute

Contents

Synopsis

Application

class Apply t where Source #

Apply something to a bunch of arguments. Preserves blocking tags (application can never resolve blocking).

Methods

apply :: t -> Args -> t Source #

applyE :: t -> Elims -> t Source #

Instances

Apply Permutation Source # 
Apply ClauseBody Source # 
Apply Clause Source # 
Apply Sort Source # 

Methods

apply :: Sort -> Args -> Sort Source #

applyE :: Sort -> Elims -> Sort Source #

Apply Term Source # 

Methods

apply :: Term -> Args -> Term Source #

applyE :: Term -> Elims -> Term Source #

Apply CompiledClauses Source # 
Apply FunctionInverse Source # 
Apply PrimFun Source # 
Apply Defn Source # 

Methods

apply :: Defn -> Args -> Defn Source #

applyE :: Defn -> Elims -> Defn Source #

Apply Projection Source # 
Apply Definition Source # 
Apply RewriteRule Source # 
Apply DisplayTerm Source # 
Apply t => Apply [t] Source # 

Methods

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

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

Apply [Occurrence] Source # 
Apply [Polarity] Source # 
Apply t => Apply (Maybe t) Source # 

Methods

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

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

Apply a => Apply (Ptr a) Source # 

Methods

apply :: Ptr a -> Args -> Ptr a Source #

applyE :: Ptr a -> Elims -> Ptr a Source #

DoDrop a => Apply (Drop a) Source # 

Methods

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

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

Apply t => Apply (Blocked t) Source # 

Methods

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

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

Subst Term a => Apply (Tele a) Source # 

Methods

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

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

Apply a => Apply (Case a) Source # 

Methods

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

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

Apply a => Apply (WithArity a) Source # 
(Apply a, Apply b) => Apply (a, b) Source # 

Methods

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

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

Apply v => Apply (Map k v) Source # 

Methods

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

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

(Apply a, Apply b, Apply c) => Apply (a, b, c) Source # 

Methods

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

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

applys :: Apply t => t -> [Term] -> t Source #

Apply to some default arguments.

apply1 :: Apply t => t -> Term -> t Source #

Apply to a single default argument.

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

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

conApp :: ConHead -> Args -> Elims -> Term Source #

Eliminate a constructed term.

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

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 Source #

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

Abstraction

class Abstract t where Source #

(abstract args v) apply args --> v[args].

Minimal complete definition

abstract

Methods

abstract :: Telescope -> t -> t Source #

Instances

Abstract Permutation Source # 
Abstract ClauseBody Source # 
Abstract Clause Source # 
Abstract Sort Source # 
Abstract Telescope Source # 
Abstract Type Source # 
Abstract Term Source # 
Abstract CompiledClauses Source # 
Abstract FunctionInverse Source # 
Abstract PrimFun Source # 
Abstract Defn Source # 
Abstract Projection Source # 
Abstract Definition Source # 
Abstract RewriteRule Source #

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

Abstract t => Abstract [t] Source # 

Methods

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

Abstract [Occurrence] Source # 
Abstract [Polarity] Source # 
Abstract t => Abstract (Maybe t) Source # 

Methods

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

DoDrop a => Abstract (Drop a) Source # 

Methods

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

Abstract a => Abstract (Case a) Source # 

Methods

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

Abstract a => Abstract (WithArity a) Source # 
Abstract v => Abstract (Map k v) Source # 

Methods

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

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

Explicit substitutions

singletonS :: DeBruijn a => Int -> a -> Substitution' a Source #

To replace index n by term u, do applySubst (singletonS n u).

liftS :: Int -> Substitution' a -> Substitution' a Source #

Lift a substitution under k binders.

composeS :: Subst a a => Substitution' a -> Substitution' a -> Substitution' a Source #

applySubst (ρ composeS σ) v == applySubst ρ (applySubst σ v)

(++#) :: DeBruijn a => [a] -> Substitution' a -> Substitution' a infixr 4 Source #

strengthenS :: Empty -> Int -> Substitution' a Source #

Γ ⊢ (strengthenS ⊥ |Δ|) : Γ,Δ

lookupS :: Subst a a => Substitution' a -> Nat -> a Source #

Substitution and raisingshiftingweakening

class DeBruijn t => Subst t a | a -> t where Source #

Apply a substitution.

Minimal complete definition

applySubst

Methods

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

Instances

Subst Term () Source # 

Methods

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

Subst Term String Source # 
Subst Term Name Source # 
Subst Term EqualityView Source # 
Subst Term ConPatternInfo Source # 
Subst Term Pattern Source # 
Subst Term ClauseBody Source # 
Subst Term LevelAtom Source # 
Subst Term PlusLevel Source # 
Subst Term Level Source # 
Subst Term Sort Source # 
Subst Term Term Source # 
Subst Term Candidate Source # 
Subst Term RewriteRule Source # 
Subst Term NLPat Source # 
Subst Term DisplayTerm Source # 
Subst Term DisplayForm Source # 
Subst Term Constraint Source # 
Subst Term AsBinding Source # 
Subst Term DotPatternInst Source # 
Subst Term ProblemRest Source # 
Subst Term SizeConstraint Source # 
Subst Term SizeMeta Source # 
Subst t a => Subst t [a] Source # 

Methods

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

Subst t a => Subst t (Maybe a) Source # 

Methods

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

Subst t a => Subst t (Dom a) Source # 

Methods

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

Subst t a => Subst t (Arg a) Source # 

Methods

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

Subst t a => Subst t (Abs a) Source # 

Methods

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

Subst t a => Subst t (Elim' a) Source # 

Methods

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

Subst t a => Subst t (Tele a) Source # 

Methods

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

Subst t a => Subst t (Blocked a) Source # 
Subst t a => Subst t (Ptr a) Source # 

Methods

applySubst :: Substitution' t -> Ptr a -> Ptr a Source #

Subst a a => Subst a (Substitution' a) Source # 
Subst Term a => Subst Term (Type' a) Source # 
Subst Term (Problem' p) Source # 
(Subst t a, Subst t b) => Subst t (a, b) Source # 

Methods

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

Subst t a => Subst t (Named name a) Source # 

Methods

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

Subst Term (SizeExpr' NamedRigid SizeMeta) Source #

Only for raise.

(Subst t a, Subst t b, Subst t c) => Subst t (a, b, c) Source # 

Methods

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

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

Methods

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

raise :: Subst t a => Nat -> a -> a Source #

raiseFrom :: Subst t a => Nat -> Nat -> a -> a Source #

subst :: Subst t a => Int -> t -> a -> a Source #

Replace de Bruijn index i by a Term in something.

strengthen :: Subst t a => Empty -> a -> a Source #

substUnder :: Subst t a => Nat -> t -> a -> a Source #

Replace what is now de Bruijn index 0, but go under n binders. substUnder n u == subst n (raise n u).

Telescopes

data TelV a Source #

Constructors

TelV 

Fields

Instances

Functor TelV Source # 

Methods

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

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

(Subst t a, Eq a) => Eq (TelV a) Source # 

Methods

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

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

(Subst t a, Ord a) => Ord (TelV a) Source # 

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) Source # 

Methods

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

show :: TelV a -> String #

showList :: [TelV a] -> ShowS #

type ListTel' a = [Dom (a, Type)] Source #

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

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

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

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

telView' :: Type -> TelView Source #

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 Source #

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

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

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

telePi :: Telescope -> Type -> Type Source #

Uses free variable analysis to introduce noAbs bindings.

telePi_ :: Telescope -> Type -> Type Source #

Everything will be a Abs.

class TeleNoAbs a where Source #

Performs void (noAbs) abstraction over telescope.

Minimal complete definition

teleNoAbs

Methods

teleNoAbs :: a -> Term -> Term Source #

dLub :: Sort -> Abs Sort -> Sort Source #

Dependent least upper bound, to assign a level to expressions like forall i -> Set i.

dLub s1 i.s2 = omega if i appears in the rigid variables of s2.

Functions on abstractions

absApp :: Subst t a => Abs a -> t -> a Source #

Instantiate an abstraction. Strict in the term.

lazyAbsApp :: Subst t a => Abs a -> t -> a Source #

Instantiate an abstraction. Lazy in the term, which allow it to be IMPOSSIBLE in the case where the variable shouldn't be used but we cannot use noabsApp. Used in Apply.

noabsApp :: Subst t a => Empty -> Abs a -> a Source #

Instantiate an abstraction that doesn't use its argument.

absBody :: Subst t a => Abs a -> a Source #

mkAbs :: (Subst t a, Free a) => ArgName -> a -> Abs a Source #

reAbs :: (Subst t a, Free a) => Abs a -> Abs a Source #

underAbs :: Subst t a => (a -> b -> b) -> a -> Abs b -> Abs b Source #

underAbs k a b applies k to a and the content of abstraction b and puts the abstraction back. a is raised if abstraction was proper such that at point of application of k and the content of b are at the same context. Precondition: a and b are at the same context at call time.

underLambdas :: Subst Term a => Int -> (a -> Term -> Term) -> a -> Term -> Term Source #

underLambdas n k a b drops n initial Lams from b, performs operation k on a and the body of b, and puts the Lams back. a is raised correctly according to the number of abstractions.

class GetBody a where Source #

Methods to retrieve the clauseBody.

Minimal complete definition

getBody, getBodyUnraised

Methods

getBody :: a -> Maybe Term Source #

Returns the properly raised clause Body, and Nothing if NoBody.

getBodyUnraised :: a -> Maybe Term Source #

Just grabs the body, without raising the de Bruijn indices. This is useful if you want to consider the body in context clauseTel.

Syntactic equality and order

Level stuff

pts :: Sort -> Sort -> Sort Source #

The `rule', if Agda is considered as a functional pure type system (pts).

TODO: This needs to be properly implemented, requiring refactoring of Agda's handling of levels. Without impredicativity or SizeUniv, Agda's pts rule is just the least upper bound, which is total and commutative. The handling of levels relies on this simplification.

data Substitution' a Source #

Substitutions.

Constructors

IdS

Identity substitution. Γ ⊢ IdS : Γ

EmptyS

Empty substitution, lifts from the empty context. 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' Source # 

Methods

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

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

Foldable Substitution' Source # 

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' Source # 

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

Pretty Substitution Source # 
KillRange Substitution Source # 
InstantiateFull Substitution Source # 
Subst a a => Subst a (Substitution' a) Source # 
Show a => Show (Substitution' a) Source # 
TermSize a => TermSize (Substitution' a) Source # 
(Show a, PrettyTCM a, Subst a a) => PrettyTCM (Substitution' a) Source # 

Orphan instances

Eq NotBlocked Source # 
Eq LevelAtom Source # 
Eq PlusLevel Source # 
Eq Level Source # 

Methods

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

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

Eq Sort Source # 

Methods

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

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

Eq Term Source #

Syntactic Term equality, ignores stuff below DontCare and sharing.

Methods

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

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

Eq Candidate Source # 
Eq Section Source # 

Methods

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

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

Eq Constraint Source # 
Ord NotBlocked Source # 
Ord LevelAtom Source # 
Ord PlusLevel Source # 
Ord Level Source # 

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 Source # 

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 Source # 

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 #

Eq (Substitution' Term) Source # 
Eq t => Eq (Blocked t) Source # 

Methods

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

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

(Subst t a, Eq a) => Eq (Tele a) Source # 

Methods

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

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

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

Syntactic Type equality, ignores sort annotations.

Methods

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

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

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

Methods

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

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

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

Methods

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

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

Ord (Substitution' Term) Source # 
Ord t => Ord (Blocked t) Source # 

Methods

compare :: Blocked t -> Blocked t -> Ordering #

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

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

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

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

max :: Blocked t -> Blocked t -> Blocked t #

min :: Blocked t -> Blocked t -> Blocked t #

(Subst t a, Ord a) => Ord (Tele a) Source # 

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) Source # 

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) Source # 

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) Source # 

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 #