MiniAgda
Safe HaskellNone
LanguageHaskell98

TreeShapedOrder

Synopsis

Documentation

newtype TSO a Source #

Tree-structured partial orders. Represented as maps from children to parents plus a non-negative distance.

Constructors

TSO 

Fields

Instances

Instances details
(Ord a, Eq a, Show a) => Show (TSO a) Source # 
Instance details

Defined in TreeShapedOrder

Methods

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

show :: TSO a -> String #

showList :: [TSO a] -> ShowS #

Eq a => Eq (TSO a) Source # 
Instance details

Defined in TreeShapedOrder

Methods

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

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

Ord a => Ord (TSO a) Source # 
Instance details

Defined in TreeShapedOrder

Methods

compare :: TSO a -> TSO a -> Ordering #

(<) :: TSO a -> TSO a -> Bool #

(<=) :: TSO a -> TSO a -> Bool #

(>) :: TSO a -> TSO a -> Bool #

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

max :: TSO a -> TSO a -> TSO a #

min :: TSO a -> TSO a -> TSO a #

empty :: TSO a Source #

Empty TSO.

insert :: (Ord a, Eq a) => a -> (Int, a) -> TSO a -> TSO a Source #

insert a b o inserts a with parent b into order o. It does not check whether the tree structure is preserved.

fromList :: (Ord a, Eq a) => [(a, (Int, a))] -> TSO a Source #

Construction from a list of child-distance-parent tuples.

parents :: (Ord a, Eq a) => a -> TSO a -> [(Int, a)] Source #

parents a0 o = [(d1,a1),..,(dn,an)] lists the parents of a0 in order, i.e., a(i+1) is parent of a(i) with distance d(i+1).

parent :: (Ord a, Eq a) => a -> TSO a -> Maybe (Int, a) Source #

parent a o returns the immediate parent, if it exists.

isAncestor :: (Ord a, Eq a) => a -> a -> TSO a -> Maybe Int Source #

isAncestor a b o = Just n if there are n steps up from a to b.

diff :: (Ord a, Eq a) => a -> a -> TSO a -> Maybe Int Source #

diff a b o = Just k if there are k steps up from a to b or (-k) steps down from b to a.

invert :: (Ord a, Eq a) => TSO a -> Map a [(Int, a)] Source #

create a map from parents to list of sons, leaves have an empty list

height :: (Ord a, Eq a) => a -> TSO a -> Maybe Int Source #

height a t = Just k if $k$ is the length of the longest path from a to a leaf. Nothing if a not in t.

increasesHeight :: (Ord a, Eq a) => a -> (Int, a) -> TSO a -> Bool Source #

increasesHeight a (n,b) t = True if n > height b t, i.e., if the insertion of a with parent b will destroy an existing minimal valuation of t

leaves :: (Ord a, Eq a) => TSO a -> [a] Source #

get the leaves of the TSO forest

pathesToForest :: (Ord a, Eq a) => [[(Int, a)]] -> Forest (Int, a) Source #

toForest :: (Ord a, Eq a) => TSO a -> Forest (Int, a) Source #

invert a tree shaped order into a forest. This can be used for printing.

l1 :: [(String, (Int, String))] Source #