HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

ModuleAgda-2.7.0.1Haskell2010

Agda.TypeChecking.SizedTypes.WarshallSolver

  • 18 types
  • 2 classes
  • 52 values
  • PackageAgda-2.7.0.1
  • Exports72
  • LanguageHaskell2010
  • LicenceMIT
  • SourceWarshallSolver.hs
valueincoming :: (Ord r, Ord f) => Graph r f a -> Node r f -> [Edge' r f a]
#

Compute list of edges that target a given node.

Note: expensive for unidirectional graph representations.

valuesetFoldl :: (b -> a -> b) -> b -> Set a -> b
#

Set.foldl does not exist in legacy versions of the containers package.

Edge weights

2 declarations
datadata Weight
#
Instances13Enum, Eq, Num, Ord, Show, Pretty, …
  • Enum WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Eq WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Num WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver

    Partial implementation of Num.

  • Ord WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Show WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Pretty WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Dioid WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • MeetSemiLattice WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Top WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Negative WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Plus Offset Weight WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Plus Weight Offset WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Plus (SizeExpr' r f) Weight (SizeExpr' r f)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
classclass Negative a where
#

Test for negativity, used to detect negative cycles.

Methods

Instances7Negative, …
  • Negative OffsetDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Negative LabelDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Negative WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Negative IntDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Negative a => Negative (Edge' r f a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver

    An edge is negative if its label is.

  • (Ord r, Ord f, Negative a) => Negative (Graph r f a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver

    A graph is negative if it contains a negative loop (diagonal edge). Makes sense on transitive graphs.

  • (Ord r, Ord f, Negative a) => Negative (Graphs r f a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver

Edge labels

2 declarations
datadata Label
#

Going from Lt to Le is pred, going from Le to Lt is succ.

X --(R,n)--> Y means X (R) Y + n. [ ... if n positive and X + (-n) (R) Y if n negative. ]

Constructors

Instances10Eq, Ord, Show, Pretty, Dioid, MeetSemiLattice, …
  • Eq LabelDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Ord LabelDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Show LabelDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Pretty LabelDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Dioid LabelDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • MeetSemiLattice LabelDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Top LabelDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Negative LabelDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • (Ord r, Ord f) => SetToInfty f (ConGraph r f)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Plus (SizeExpr' r f) Label (SizeExpr' r f)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver

Semiring with idempotent + == dioid

0 declarations

Graphs

0 declarations

Nodes

datadata Node rigid flex
#

Constructors

Instances13SetToInfty, Eq, Ord, Show, Pretty, Dioid, …
  • Eq f => SetToInfty f (Node r f)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • (Ord r, Ord f) => SetToInfty f (ConGraph r f)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Eq f => SetToInfty f (Edge' r f a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • (Eq rigid, Eq flex) => Eq (Node rigid flex)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • (Ord rigid, Ord flex) => Ord (Node rigid flex)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • (Show rigid, Show flex) => Show (Node rigid flex)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • (Pretty rigid, Pretty flex) => Pretty (Node rigid flex)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • (Ord r, Ord f, Dioid a) => Dioid (Edge' r f a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • (Ord r, Ord f, MeetSemiLattice a) => MeetSemiLattice (Edge' r f a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • (Ord r, Ord f, Top a) => Top (Edge' r f a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Negative a => Negative (Edge' r f a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver

    An edge is negative if its label is.

  • (Ord r, Ord f, Negative a) => Negative (Graph r f a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver

    A graph is negative if it contains a negative loop (diagonal edge). Makes sense on transitive graphs.

  • (Ord r, Ord f, Negative a) => Negative (Graphs r f a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver

Edges

Graphs

valuementions
  1. :: (Ord r, Ord f)
  2. => Node r f
  3. -> Graphs r f a
  4. -> (Graphs r f a, Graphs r f a)
#

Split a list of graphs gs into those that mention node n and those that do not. If n is zero or infinity, we regard it as "not mentioned".

valueimplies
  1. :: (Ord r, Ord f, Pretty r, Pretty f, Pretty a, Top a, Ord a, Negative a)
  2. => Graph r f a
  3. -> Graph r f a
  4. -> Bool
#

h implies g if any edge in g between rigids and constants is implied by a corresponding edge in h, which means that the edge in g carries at most the information of the one in h.

Application: Constraint implication: Constraints are compatible with hypotheses.

typetype Error = TCM Doc
#

Error messages produced by the solver.

classclass SetToInfty f a where
#

Methods

Instances3SetToInfty
  • Eq f => SetToInfty f (Node r f)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • (Ord r, Ord f) => SetToInfty f (ConGraph r f)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
  • Eq f => SetToInfty f (Edge' r f a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver

Compute solution from constraint graph.

19 declarations
valuesmallest :: (Ord r, Ord f) => HypGraph r f -> [Node r f] -> [Node r f]
#

Compute the relative minima in a set of nodes (those that do not have a predecessor in the set).

valuelargest :: (Ord r, Ord f) => HypGraph r f -> [Node r f] -> [Node r f]
#

Compute the relative maxima in a set of nodes (those that do not have a successor in the set).

valuecommonSuccs
  1. :: (Ord r, Ord f)
  2. => Graph r f a
  3. -> [Node r f]
  4. -> Map (Node r f) [Edge' r f a]
#

Given source nodes n1,n2,... find all target nodes m1,m2, such that for all j, there are edges n_i --l_ij--> m_j for all i. Return these edges as a map from target notes to a list of edges. We assume the graph is reflexive-transitive.

valuecommonPreds
  1. :: (Ord r, Ord f)
  2. => Graph r f a
  3. -> [Node r f]
  4. -> Map (Node r f) [Edge' r f a]
#

Given target nodes m1,m2,... find all source nodes n1,n2, such that for all j, there are edges n_i --l_ij--> m_j for all i. Return these edges as a map from target notes to a list of edges. We assume the graph is reflexive-transitive.

Verify solution

2 declarations
valueiterateSolver
  1. :: (Ord r, Ord f, Pretty r, Pretty f, PrettyTCM f, Show r, Show f)
  2. => Polarities f

    Meta variable polarities (prefer lower or upper solution?).

  3. -> HypGraph r f

    Hypotheses (assumed to have no metas, so, fixed during iteration).

  4. -> [Constraint' r f]

    Constraints to solve.

  5. -> Solution r f

    Previous substitution (already applied to constraints).

  6. -> Either Error (Solution r f)

    Accumulated substition.

#

Iterate solver until no more metas can be solved.

This might trigger a (wanted) error on the second iteration (see Issue 2096) which would otherwise go unnoticed.

Tests

2 declarations