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

Agda.Termination.CallMatrix

Synopsis

Documentation

Call matrix indices = function argument indices.

Machine integer Int is sufficient, since we cannot index more arguments than we have addresses on our machine.

newtype CallMatrix' a Source #

Call matrices.

A call matrix for a call f --> g has dimensions ar(g) × ar(f).

Each column corresponds to one formal argument of caller f. Each row corresponds to one argument in the call to g.

In the presence of dot patterns, a call argument can be related to several different formal arguments of f.

See e.g. testsucceedDotPatternTermination.agda:

    data D : Nat -> Set where
cz : D zero
c1 : forall n -> D n -> D (suc n)
c2 : forall n -> D n -> D n

f : forall n -> D n -> Nat
f .zero    cz        = zero
f .(suc n) (c1  n d) = f n (c2 n d)
f n        (c2 .n d) = f n d


Call matrices (without guardedness) are

          -1 -1   n < suc n  and       n <  c1 n d
?  =                   c2 n d <= c1 n d

= -1   n <= n     and  n < c2 n d
? -1                   d < c2 n d


Here is a part of the original documentation for call matrices (kept for historical reasons):

This datatype encodes information about a single recursive function application. The columns of the call matrix stand for source function arguments (patterns). The rows of the matrix stand for target function arguments. Element (i, j) in the matrix should be computed as follows:

• lt (less than) if the j-th argument to the target function is structurally strictly smaller than the i-th pattern.
• le (less than or equal) if the j-th argument to the target function is structurally smaller than the i-th pattern.
• unknown otherwise.

Constructors

 CallMatrix Fieldsmat :: Matrix ArgumentIndex a

Instances

 Source # Methodsfmap :: (a -> b) -> CallMatrix' a -> CallMatrix' b #(<\$) :: a -> CallMatrix' b -> CallMatrix' a # Source # Methodsfold :: Monoid m => CallMatrix' m -> m #foldMap :: Monoid m => (a -> m) -> CallMatrix' a -> m #foldr :: (a -> b -> b) -> b -> CallMatrix' a -> b #foldr' :: (a -> b -> b) -> b -> CallMatrix' a -> b #foldl :: (b -> a -> b) -> b -> CallMatrix' a -> b #foldl' :: (b -> a -> b) -> b -> CallMatrix' a -> b #foldr1 :: (a -> a -> a) -> CallMatrix' a -> a #foldl1 :: (a -> a -> a) -> CallMatrix' a -> a #toList :: CallMatrix' a -> [a] #null :: CallMatrix' a -> Bool #length :: CallMatrix' a -> Int #elem :: Eq a => a -> CallMatrix' a -> Bool #maximum :: Ord a => CallMatrix' a -> a #minimum :: Ord a => CallMatrix' a -> a #sum :: Num a => CallMatrix' a -> a #product :: Num a => CallMatrix' a -> a # Source # Methodstraverse :: Applicative f => (a -> f b) -> CallMatrix' a -> f (CallMatrix' b) #sequenceA :: Applicative f => CallMatrix' (f a) -> f (CallMatrix' a) #mapM :: Monad m => (a -> m b) -> CallMatrix' a -> m (CallMatrix' b) #sequence :: Monad m => CallMatrix' (m a) -> m (CallMatrix' a) # Source # Methodsshrink :: CallMatrix -> [CallMatrix] # Source # Methods Source # Call matrix multiplication.f --(m1)--> g --(m2)--> h is combined to f --(m2 mul m1)--> hNote the reversed order of multiplication: The matrix c1 of the second call g-->h in the sequence f-->g-->h is multiplied with the matrix c2 of the first call.Preconditions: m1 has dimensions ar(g) × ar(f). m2 has dimensions ar(h) × ar(g).Postcondition: m1 >*< m2 has dimensions ar(h) × ar(f). Methods Eq a => Eq (CallMatrix' a) Source # Methods(==) :: CallMatrix' a -> CallMatrix' a -> Bool #(/=) :: CallMatrix' a -> CallMatrix' a -> Bool # Ord a => Ord (CallMatrix' a) Source # Methodscompare :: CallMatrix' a -> CallMatrix' a -> Ordering #(<) :: CallMatrix' a -> CallMatrix' a -> Bool #(<=) :: CallMatrix' a -> CallMatrix' a -> Bool #(>) :: CallMatrix' a -> CallMatrix' a -> Bool #(>=) :: CallMatrix' a -> CallMatrix' a -> Bool #max :: CallMatrix' a -> CallMatrix' a -> CallMatrix' a #min :: CallMatrix' a -> CallMatrix' a -> CallMatrix' a # (Show a, HasZero a) => Show (CallMatrix' a) Source # MethodsshowsPrec :: Int -> CallMatrix' a -> ShowS #show :: CallMatrix' a -> String #showList :: [CallMatrix' a] -> ShowS # (HasZero a, CoArbitrary a) => CoArbitrary (CallMatrix' a) Source # Methodscoarbitrary :: CallMatrix' a -> Gen b -> Gen b # Source # Methods Source # Methods HasZero a => Diagonal (CallMatrix' a) a Source # Methodsdiagonal :: CallMatrix' a -> [a] Source #

class CallComb a where Source #

Call matrix multiplication and call combination.

Minimal complete definition

(>*<)

Methods

(>*<) :: (?cutoff :: CutOff) => a -> a -> a Source #

Instances

 Source # Call matrix multiplication.f --(m1)--> g --(m2)--> h is combined to f --(m2 mul m1)--> hNote the reversed order of multiplication: The matrix c1 of the second call g-->h in the sequence f-->g-->h is multiplied with the matrix c2 of the first call.Preconditions: m1 has dimensions ar(g) × ar(f). m2 has dimensions ar(h) × ar(g).Postcondition: m1 >*< m2 has dimensions ar(h) × ar(f). Methods Monoid cinfo => CallComb (CMSet cinfo) Source # Call matrix set product is the Cartesian product. Methods(>*<) :: CMSet cinfo -> CMSet cinfo -> CMSet cinfo Source # Monoid cinfo => CallComb (CallMatrixAug cinfo) Source # Augmented call matrix multiplication. Methods(>*<) :: CallMatrixAug cinfo -> CallMatrixAug cinfo -> CallMatrixAug cinfo Source #

Call matrix augmented with path information.

data CallMatrixAug cinfo Source #

Call matrix augmented with path information.

Constructors

 CallMatrixAug FieldsaugCallMatrix :: CallMatrixThe matrix of the (composed call).augCallInfo :: cinfoMeta info, like call path.

Instances

 Eq cinfo => Eq (CallMatrixAug cinfo) Source # Methods(==) :: CallMatrixAug cinfo -> CallMatrixAug cinfo -> Bool #(/=) :: CallMatrixAug cinfo -> CallMatrixAug cinfo -> Bool # Show cinfo => Show (CallMatrixAug cinfo) Source # MethodsshowsPrec :: Int -> CallMatrixAug cinfo -> ShowS #show :: CallMatrixAug cinfo -> String #showList :: [CallMatrixAug cinfo] -> ShowS # Arbitrary cinfo => Arbitrary (CallMatrixAug cinfo) Source # Methodsarbitrary :: Gen (CallMatrixAug cinfo) #shrink :: CallMatrixAug cinfo -> [CallMatrixAug cinfo] # CoArbitrary cinfo => CoArbitrary (CallMatrixAug cinfo) Source # Methodscoarbitrary :: CallMatrixAug cinfo -> Gen b -> Gen b # Pretty cinfo => Pretty (CallMatrixAug cinfo) Source # Methodspretty :: CallMatrixAug cinfo -> Doc Source #prettyPrec :: Int -> CallMatrixAug cinfo -> Doc Source # PartialOrd (CallMatrixAug cinfo) Source # Methods NotWorse (CallMatrixAug cinfo) Source # MethodsnotWorse :: CallMatrixAug cinfo -> CallMatrixAug cinfo -> Bool Source # Monoid cinfo => CallComb (CallMatrixAug cinfo) Source # Augmented call matrix multiplication. Methods(>*<) :: CallMatrixAug cinfo -> CallMatrixAug cinfo -> CallMatrixAug cinfo Source # Diagonal (CallMatrixAug cinfo) Order Source # Methodsdiagonal :: CallMatrixAug cinfo -> [Order] Source # Singleton (CallMatrixAug cinfo) (CMSet cinfo) Source # Methodssingleton :: CallMatrixAug cinfo -> CMSet cinfo Source #

noAug :: Monoid cinfo => CallMatrix -> CallMatrixAug cinfo Source #

Non-augmented call matrix.

Sets of incomparable call matrices augmented with path information.

newtype CMSet cinfo Source #

Sets of incomparable call matrices augmented with path information. Use overloaded null, empty, singleton, mappend.

Constructors

 CMSet FieldscmSet :: Favorites (CallMatrixAug cinfo)

Instances

 Show cinfo => Show (CMSet cinfo) Source # MethodsshowsPrec :: Int -> CMSet cinfo -> ShowS #show :: CMSet cinfo -> String #showList :: [CMSet cinfo] -> ShowS # Monoid (CMSet cinfo) Source # Methodsmempty :: CMSet cinfo #mappend :: CMSet cinfo -> CMSet cinfo -> CMSet cinfo #mconcat :: [CMSet cinfo] -> CMSet cinfo # Arbitrary cinfo => Arbitrary (CMSet cinfo) Source # Methodsarbitrary :: Gen (CMSet cinfo) #shrink :: CMSet cinfo -> [CMSet cinfo] # CoArbitrary cinfo => CoArbitrary (CMSet cinfo) Source # Methodscoarbitrary :: CMSet cinfo -> Gen b -> Gen b # Pretty cinfo => Pretty (CMSet cinfo) Source # Methodspretty :: CMSet cinfo -> Doc Source #prettyPrec :: Int -> CMSet cinfo -> Doc Source # Null (CMSet cinfo) Source # Methodsempty :: CMSet cinfo Source #null :: CMSet cinfo -> Bool Source # Monoid cinfo => CallComb (CMSet cinfo) Source # Call matrix set product is the Cartesian product. Methods(>*<) :: CMSet cinfo -> CMSet cinfo -> CMSet cinfo Source # Singleton (CallMatrixAug cinfo) (CMSet cinfo) Source # Methodssingleton :: CallMatrixAug cinfo -> CMSet cinfo Source #

insert :: CallMatrixAug cinfo -> CMSet cinfo -> CMSet cinfo Source #

Insert into a call matrix set.

union :: CMSet cinfo -> CMSet cinfo -> CMSet cinfo Source #

Union two call matrix sets.

toList :: CMSet cinfo -> [CallMatrixAug cinfo] Source #

Convert into a list of augmented call matrices.

Generators and tests

CallMatrix

Generates a call matrix of the given size.