| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Agda.TypeChecking.Conversion
Synopsis
- antiUnify :: ProblemId -> Type -> Term -> Term -> TCM Term
- antiUnifyArgs :: ProblemId -> Dom Type -> Arg Term -> Arg Term -> TCM (Arg Term)
- antiUnifyElims :: ProblemId -> Type -> Term -> Elims -> Elims -> TCM Term
- antiUnifyType :: ProblemId -> Type -> Type -> TCM Type
- assignE :: CompareDirection -> MetaId -> Elims -> Term -> CompareAs -> (Term -> Term -> TCM ()) -> TCM ()
- bothAbsurd :: QName -> QName -> TCM Bool
- coerce :: Comparison -> Term -> Type -> Type -> TCM Term
- coerceSize :: Comparison -> Term -> Type -> Type -> TCM ()
- compareArgs :: [Polarity] -> [IsForced] -> Type -> Term -> Args -> Args -> TCM ()
- compareAs :: Comparison -> CompareAs -> Term -> Term -> TCM ()
- compareAs' :: Comparison -> CompareAs -> Term -> Term -> TCM ()
- compareAsDir :: CompareDirection -> CompareAs -> Term -> Term -> TCM ()
- compareAtom :: Comparison -> CompareAs -> Term -> Term -> TCM ()
- compareAtomDir :: CompareDirection -> CompareAs -> Term -> Term -> TCM ()
- compareDom :: Comparison -> Dom Type -> Dom Type -> Abs Type -> Abs Type -> TCM () -> TCM () -> TCM ()
- compareElims :: [Polarity] -> [IsForced] -> Type -> Term -> [Elim] -> [Elim] -> TCM ()
- compareInterval :: Comparison -> Type -> Term -> Term -> TCM ()
- compareIrrelevant :: Type -> Term -> Term -> TCM ()
- compareLevel :: Comparison -> Level -> Level -> TCM ()
- compareMetas :: Comparison -> CompareAs -> MetaId -> Elims -> MetaId -> Elims -> TCM ()
- compareSort :: Comparison -> Sort -> Sort -> TCM ()
- compareTerm :: Comparison -> Type -> Term -> Term -> TCM ()
- compareTerm' :: Comparison -> Type -> Term -> Term -> TCM ()
- compareTermOnFace :: Comparison -> Term -> Type -> Term -> Term -> TCM ()
- compareTermOnFace' :: (Substitution -> Comparison -> Type -> Term -> Term -> TCM ()) -> Comparison -> Term -> Type -> Term -> Term -> TCM ()
- compareType :: Comparison -> Type -> Type -> TCM ()
- compareWithPol :: Polarity -> (Comparison -> a -> a -> TCM ()) -> a -> a -> TCM ()
- computeElimHeadType :: QName -> Elims -> Elims -> TCM Type
- computeRewHeadType :: Int -> RewriteHead -> Elims -> Elims -> TCM Type
- convError :: TypeError -> TCM ()
- equalAtom :: CompareAs -> Term -> Term -> TCM ()
- equalLevel :: Level -> Level -> TCM ()
- equalSort :: Sort -> Sort -> TCM ()
- equalTerm :: Type -> Term -> Term -> TCM ()
- equalTermOnFace :: Term -> Type -> Term -> Term -> TCM ()
- equalType :: Type -> Type -> TCM ()
- forallFaceMaps :: Term -> (IntMap Bool -> Blocker -> Term -> TCM a) -> (IntMap Bool -> Substitution -> TCM a) -> TCM [a]
- guardPointerEquality :: a -> a -> String -> TCM () -> TCM ()
- intersectVars :: Elims -> Elims -> Maybe [Bool]
- isCanonical :: [Conj] -> Bool
- leqConj :: Conj -> Conj -> TCM Bool
- leqInterval :: [Conj] -> [Conj] -> TCM Bool
- leqLevel :: Level -> Level -> TCM ()
- leqSort :: Sort -> Sort -> TCM ()
- leqType :: Type -> Type -> TCM ()
- polFromCmp :: Comparison -> Polarity
- sameVars :: Elims -> Elims -> Bool
- tryConversion :: TCM () -> TCM Bool
- tryConversion' :: TCM a -> TCM (Maybe a)
- type Conj = (IntMap BoolSet, [Term])
- failConversion :: (MonadTCError m, HasBuiltins m) => Comparison -> Term -> Term -> CompareAs -> m a
Documentation
antiUnify :: ProblemId -> Type -> Term -> Term -> TCM Term Source #
When comparing argument spines (in compareElims) where the first arguments don't match, we keep going, substituting the anti-unification of the two terms in the telescope. More precisely:
@
(u = v : A)[pid] w = antiUnify pid A u v us = vs : Δ[w/x]
-------------------------------------------------------------
u us = v vs : (x : A) Δ
@
The simplest case of anti-unification is to return a fresh metavariable (created by blockTermOnProblem), but if there's shared structure between the two terms we can expose that.
This is really a crutch that lets us get away with things that otherwise would require heterogenous conversion checking. See for instance issue #2384.
assignE :: CompareDirection -> MetaId -> Elims -> Term -> CompareAs -> (Term -> Term -> TCM ()) -> TCM () Source #
Try to assign meta. If meta is projected, try to eta-expand and run conversion check again.
coerce :: Comparison -> Term -> Type -> Type -> TCM Term Source #
coerce v a b coerces v : a to type b, returning a v' : b
with maybe extra hidden applications or hidden abstractions.
In principle, this function can host coercive subtyping, but currently it only tries to fix problems with hidden function types.
coerceSize :: Comparison -> Term -> Type -> Type -> TCM () Source #
Account for situations like k : (Size< j) <= (Size< k + 1)
Actually, the semantics is
(Size<= k) ∩ (Size< j) ⊆ rhs
which gives a disjunctive constraint. Mmmh, looks like stuff
TODO.
For now, we do a cheap heuristics.
compareArgs :: [Polarity] -> [IsForced] -> Type -> Term -> Args -> Args -> TCM () Source #
Type-directed equality on argument lists
compareAs :: Comparison -> CompareAs -> Term -> Term -> TCM () Source #
Type directed equality on terms or types.
compareAs' :: Comparison -> CompareAs -> Term -> Term -> TCM () Source #
compareAsDir :: CompareDirection -> CompareAs -> Term -> Term -> TCM () Source #
compareAtom :: Comparison -> CompareAs -> Term -> Term -> TCM () Source #
Syntax directed equality on atomic values
compareAtomDir :: CompareDirection -> CompareAs -> Term -> Term -> TCM () Source #
Arguments
| :: Comparison |
|
| -> Dom Type |
|
| -> Dom Type |
|
| -> Abs Type |
|
| -> Abs Type |
|
| -> TCM () | Error continuation |
| -> TCM () | Success continuation |
| -> TCM () |
Check whether a1 and continue in context extended by cmp a2a1.
compareElims :: [Polarity] -> [IsForced] -> Type -> Term -> [Elim] -> [Elim] -> TCM () Source #
compareElims pols a v els1 els2 performs type-directed equality on eliminator spines.
t is the type of the head v.
Note: since TCM is lazy in return values from (>>=), it is
important that compareElims in non-tail position be called as () <-
compareElims pols a v e1 e2 so that any internal invariants upheld
by returning IMPOSSIBLE actually get checked.
compareInterval :: Comparison -> Type -> Term -> Term -> TCM () Source #
compareIrrelevant :: Type -> Term -> Term -> TCM () Source #
Compare two terms in irrelevant position. This always succeeds. However, we can dig for solutions of irrelevant metas in the terms we compare. (Certainly not the systematic solution, that'd be proof search...)
compareLevel :: Comparison -> Level -> Level -> TCM () Source #
compareMetas :: Comparison -> CompareAs -> MetaId -> Elims -> MetaId -> Elims -> TCM () Source #
Check whether x xArgs cmp y yArgs
compareSort :: Comparison -> Sort -> Sort -> TCM () Source #
compareTerm :: Comparison -> Type -> Term -> Term -> TCM () Source #
Type directed equality on values.
compareTerm' :: Comparison -> Type -> Term -> Term -> TCM () Source #
compareTermOnFace :: Comparison -> Term -> Type -> Term -> Term -> TCM () Source #
compareTermOnFace' :: (Substitution -> Comparison -> Type -> Term -> Term -> TCM ()) -> Comparison -> Term -> Type -> Term -> Term -> TCM () Source #
compareType :: Comparison -> Type -> Type -> TCM () Source #
Equality on Types
compareWithPol :: Polarity -> (Comparison -> a -> a -> TCM ()) -> a -> a -> TCM () Source #
computeElimHeadType :: QName -> Elims -> Elims -> TCM Type Source #
Compute the head type of an elimination. For projection-like functions this requires inferring the type of the principal argument.
computeRewHeadType :: Int -> RewriteHead -> Elims -> Elims -> TCM Type Source #
Compute the type of a rewrite rule head. For projection-like functions, this requires inferring the type of the principal argument, using the eliminations.
equalTermOnFace :: Term -> Type -> Term -> Term -> TCM () Source #
equalTermOnFace φ A u v = _ , φ ⊢ u = v : A
forallFaceMaps :: Term -> (IntMap Bool -> Blocker -> Term -> TCM a) -> (IntMap Bool -> Substitution -> TCM a) -> TCM [a] Source #
guardPointerEquality :: a -> a -> String -> TCM () -> TCM () Source #
guardPointerEquality x y s m behaves as m if x and y are equal as pointers,
or does nothing otherwise.
Use with care, see the documentation for unsafeComparePointers
intersectVars :: Elims -> Elims -> Maybe [Bool] Source #
intersectVars us vs checks whether all relevant elements in us and vs
are variables, and if yes, returns a prune list which says True for
arguments which are different and can be pruned.
isCanonical :: [Conj] -> Bool Source #
leqConj :: Conj -> Conj -> TCM Bool Source #
leqConj r q = r ≤ q in the I lattice, when r and q are conjuctions. ' (∧ r_i) ≤ (∧ q_j) iff ' (∧ r_i) ∧ (∧ q_j) = (∧ r_i) iff ' {r_i | i} ∪ {q_j | j} = {r_i | i} iff ' {q_j | j} ⊆ {r_i | i}
leqInterval :: [Conj] -> [Conj] -> TCM Bool Source #
leqInterval r q = r ≤ q in the I lattice. (∨ r_i) ≤ (∨ q_j) iff ∀ i. ∃ j. r_i ≤ q_j
leqSort :: Sort -> Sort -> TCM () Source #
Check that the first sort is less or equal to the second.
We can put SizeUniv below Inf, but otherwise, it is
unrelated to the other universes.
polFromCmp :: Comparison -> Polarity Source #
sameVars :: Elims -> Elims -> Bool Source #
Check if to lists of arguments are the same (and all variables). Precondition: the lists have the same length.
tryConversion :: TCM () -> TCM Bool Source #
Try whether a computation runs without errors or new constraints (may create new metas, though). Restores state upon failure.
Arguments
| :: (MonadTCError m, HasBuiltins m) | |
| => Comparison | Equality or subtyping? |
| -> Term | See |
| -> Term | See |
| -> CompareAs | Will be converted to a |
| -> m a |
Throw a floating ConversionError, given the arguments of
compareAs.