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

Safe Haskell | None
Language | Haskell2010

Agda.TypeChecking.Rewriting.NonLinMatch

Description

Non-linear matching of the lhs of a rewrite rule against a neutral term.

Given a lhs

Δ ⊢ lhs : B

and a candidate term

Γ ⊢ t : A

we seek a substitution Γ ⊢ σ : Δ such that

Γ ⊢ B[σ] = A and Γ ⊢ lhs[σ] = t : A

Synopsis

- class PatternFrom a b where
- type NLM = ExceptT Blocked_ (StateT NLMState ReduceM)
- data NLMState = NLMState {
  - _nlmSub :: Sub
  - _nlmEqs :: PostponedEquations
  }
- nlmSub :: Lens' Sub NLMState
- nlmEqs :: Lens' PostponedEquations NLMState
- liftRed :: ReduceM a -> NLM a
- runNLM :: NLM () -> ReduceM (Either Blocked_ NLMState)
- traceSDocNLM :: VerboseKey -> Int -> TCM Doc -> NLM a -> NLM a
- matchingBlocked :: Blocked_ -> NLM ()
- tellSub :: Relevance -> Int -> Term -> NLM ()
- tellEq :: Telescope -> Telescope -> Term -> Term -> NLM ()
- type Sub = IntMap (Relevance, Term)
- data PostponedEquation = PostponedEquation {
  - eqFreeVars :: Telescope
  - eqLhs :: Term
  - eqRhs :: Term
  }
- type PostponedEquations = [PostponedEquation]
- class Match a b where
- reallyFree :: (Reduce a, Normalise a, Free' a FreeVars) => (Int -> Bool) -> a -> ReduceM (Either Blocked_ (Maybe a))
- makeSubstitution :: Telescope -> Sub -> Substitution
- checkPostponedEquations :: Substitution -> PostponedEquations -> ReduceM (Maybe Blocked_)
- nonLinMatch :: Match a b => Telescope -> a -> b -> ReduceM (Either Blocked_ Substitution)
- equal :: Term -> Term -> ReduceM (Maybe Blocked_)
- normaliseB' :: (Reduce t, Normalise t) => t -> ReduceM (Blocked t)
- class RaiseNLP a where

# Documentation

class PatternFrom a b where #

Turn a term into a non-linear pattern, treating the free variables as pattern variables. The first argument indicates the relevance we are working under: if this is Irrelevant, then we construct a pattern that never fails to match. The second argument is the number of bound variables (from pattern lambdas).

Minimal complete definition

patternFrom

Methods

patternFrom :: Relevance -> Int -> a -> TCM b #

Instances

PatternFrom Sort NLPat # |
Methods patternFrom :: Relevance -> Int -> Sort -> TCM NLPat #
PatternFrom Type NLPType # |
Methods patternFrom :: Relevance -> Int -> Type -> TCM NLPType #
PatternFrom Term NLPat # |
Methods patternFrom :: Relevance -> Int -> Term -> TCM NLPat #
PatternFrom a b => PatternFrom [a] [b] # |
Methods patternFrom :: Relevance -> Int -> [a] -> TCM [b] #
PatternFrom a b => PatternFrom (Dom a) (Dom b) # |
Methods patternFrom :: Relevance -> Int -> Dom a -> TCM (Dom b) #
PatternFrom a b => PatternFrom (Arg a) (Arg b) # |
Methods patternFrom :: Relevance -> Int -> Arg a -> TCM (Arg b) #
PatternFrom a b => PatternFrom (Abs a) (Abs b) # |
Methods patternFrom :: Relevance -> Int -> Abs a -> TCM (Abs b) #
PatternFrom a NLPat => PatternFrom (Elim' a) (Elim' NLPat) # |
Methods patternFrom :: Relevance -> Int -> Elim' a -> TCM (Elim' NLPat) #

type NLM = ExceptT Blocked_ (StateT NLMState ReduceM) #

Monad for non-linear matching.

data NLMState #

Constructors

NLMState |
Fields _nlmSub :: Sub _nlmEqs :: PostponedEquations

Instances

Null NLMState # |
Methods empty :: NLMState # null :: NLMState -> Bool #
HasOptions NLM # |
Methods pragmaOptions :: NLM PragmaOptions # commandLineOptions :: NLM CommandLineOptions #

nlmSub :: Lens' Sub NLMState #

nlmEqs :: Lens' PostponedEquations NLMState #

liftRed :: ReduceM a -> NLM a #

runNLM :: NLM () -> ReduceM (Either Blocked_ NLMState) #

traceSDocNLM :: VerboseKey -> Int -> TCM Doc -> NLM a -> NLM a #

matchingBlocked :: Blocked_ -> NLM () #

tellSub :: Relevance -> Int -> Term -> NLM () #

Add substitution `i |-> v` to result of matching.

tellEq :: Telescope -> Telescope -> Term -> Term -> NLM () #

type Sub = IntMap (Relevance, Term) #

data PostponedEquation #

Matching against a term produces a constraint which we have to verify after applying the substitution computed by matching.

Constructors

PostponedEquation |
Fields eqFreeVars :: Telescope Telescope of free variables in the equation eqLhs :: Term Term from pattern, living in pattern context. eqRhs :: Term Term from scrutinee, living in context where matching was invoked.

type PostponedEquations = [PostponedEquation] #

class Match a b where #

Match a non-linear pattern against a neutral term, returning a substitution.

Minimal complete definition

match

Methods

match :: Relevance -> Telescope -> Telescope -> a -> b -> NLM () #

Instances

Match NLPType Type # |
Methods match :: Relevance -> Telescope -> Telescope -> NLPType -> Type -> NLM () #
Match NLPat Level # |
Methods match :: Relevance -> Telescope -> Telescope -> NLPat -> Level -> NLM () #
Match NLPat Sort # |
Methods match :: Relevance -> Telescope -> Telescope -> NLPat -> Sort -> NLM () #
Match NLPat Term # |
Methods match :: Relevance -> Telescope -> Telescope -> NLPat -> Term -> NLM () #
Match a b => Match [a] [b] # |
Methods match :: Relevance -> Telescope -> Telescope -> [a] -> [b] -> NLM () #
Match a b => Match (Dom a) (Dom b) # |
Methods match :: Relevance -> Telescope -> Telescope -> Dom a -> Dom b -> NLM () #
Match a b => Match (Arg a) (Arg b) # |
Methods match :: Relevance -> Telescope -> Telescope -> Arg a -> Arg b -> NLM () #
(Match a b, RaiseNLP a, Subst t2 b) => Match (Abs a) (Abs b) # |
Methods match :: Relevance -> Telescope -> Telescope -> Abs a -> Abs b -> NLM () #
Match a b => Match (Elim' a) (Elim' b) # |
Methods match :: Relevance -> Telescope -> Telescope -> Elim' a -> Elim' b -> NLM () #

reallyFree :: (Reduce a, Normalise a, Free' a FreeVars) => (Int -> Bool) -> a -> ReduceM (Either Blocked_ (Maybe a)) #

makeSubstitution :: Telescope -> Sub -> Substitution #

checkPostponedEquations :: Substitution -> PostponedEquations -> ReduceM (Maybe Blocked_) #

nonLinMatch :: Match a b => Telescope -> a -> b -> ReduceM (Either Blocked_ Substitution) #

equal :: Term -> Term -> ReduceM (Maybe Blocked_) #

Untyped βη-equality, does not handle things like empty record types. Returns `Nothing` if the terms are equal, or `Just b` if the terms are not (where b contains information about possible metas blocking the comparison)

normaliseB' :: (Reduce t, Normalise t) => t -> ReduceM (Blocked t) #

Normalise the given term but also preserve blocking tags TODO: implement a more efficient version of this.

class RaiseNLP a where #

Raise (bound) variables in a NLPat

Minimal complete definition

raiseNLPFrom

Methods

raiseNLPFrom :: Int -> Int -> a -> a #

raiseNLP :: Int -> a -> a #

Instances

RaiseNLP NLPType # |
Methods raiseNLPFrom :: Int -> Int -> NLPType -> NLPType # raiseNLP :: Int -> NLPType -> NLPType #
RaiseNLP NLPat # |
Methods raiseNLPFrom :: Int -> Int -> NLPat -> NLPat # raiseNLP :: Int -> NLPat -> NLPat #
RaiseNLP a => RaiseNLP [a] # |
Methods raiseNLPFrom :: Int -> Int -> [a] -> [a] # raiseNLP :: Int -> [a] -> [a] #
RaiseNLP a => RaiseNLP (Maybe a) # |
Methods raiseNLPFrom :: Int -> Int -> Maybe a -> Maybe a # raiseNLP :: Int -> Maybe a -> Maybe a #
RaiseNLP a => RaiseNLP (Dom a) # |
Methods raiseNLPFrom :: Int -> Int -> Dom a -> Dom a # raiseNLP :: Int -> Dom a -> Dom a #
RaiseNLP a => RaiseNLP (Arg a) # |
Methods raiseNLPFrom :: Int -> Int -> Arg a -> Arg a # raiseNLP :: Int -> Arg a -> Arg a #
RaiseNLP a => RaiseNLP (Abs a) # |
Methods raiseNLPFrom :: Int -> Int -> Abs a -> Abs a # raiseNLP :: Int -> Abs a -> Abs a #
RaiseNLP a => RaiseNLP (Elim' a) # |
Methods raiseNLPFrom :: Int -> Int -> Elim' a -> Elim' a # raiseNLP :: Int -> Elim' a -> Elim' a #