Agda- A dependently typed functional programming language and proof assistant

Safe HaskellNone





class Apply t where Source

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

Minimal complete definition



apply :: t -> Args -> t Source

applyE :: t -> Elims -> t Source

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

Apply to a single 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

The type must contain the right number of pis without have to perform any reduction.


class Abstract t where Source

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


abstract :: Telescope -> t -> t Source

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

Explicit substitutions

singletonS :: Int -> Term -> Substitution Source

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

liftS :: Int -> Substitution -> Substitution Source

Lift a substitution under k binders.

composeS :: Substitution -> Substitution -> Substitution Source

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

Substitution and raisingshiftingweakening

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

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

subst :: Subst t => Int -> Term -> t -> t Source

Replace de Bruijn index i by a Term in something.

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

substUnder :: Subst t => Nat -> Term -> t -> t Source

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


data TelV a Source




theTel :: Tele (Dom a)
theCore :: a


Functor TelV Source 
(Eq a, Subst a) => Eq (TelV a) Source 
(Ord a, Subst a) => Ord (TelV a) Source 
Show a => Show (TelV a) Source 

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.

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.


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 => Abs t -> Term -> t Source

Instantiate an abstraction. Strict in the term.

lazyAbsApp :: Subst t => Abs t -> Term -> t 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 => Empty -> Abs t -> t Source

Instantiate an abstraction that doesn't use its argument.

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

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

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

underAbs :: Subst 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 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.


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 Source




Identity substitution. Γ ⊢ IdS : Γ


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

Term :# Substitution infixr 4

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

Strengthen Empty Substitution

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

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

Lift !Int Substitution

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