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
Compute list of edges that start in a given node.
Compute list of edges that target a given node.
Note: expensive for unidirectional graph representations.
Set.foldl does not exist in legacy versions of the containers package.
Floyd-Warshall algorithm.
Edge weights
2 declarationsInstances13Enum, Eq, Num, Ord, Show, Pretty, …
Enum WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverEq WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverNum WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverPartial implementation of
Num.Ord WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverShow WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverPretty WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverDioid WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverMeetSemiLattice WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverTop WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverNegative WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverPlus Offset Weight WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverPlus Weight Offset WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverPlus (SizeExpr' r f) Weight (SizeExpr' r f)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
Instances7Negative, …
Negative OffsetDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverNegative LabelDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverNegative WeightDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverNegative IntDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverNegative a => Negative (Edge' r f a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverAn 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.WarshallSolverA 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 declarationsGoing 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. ]
Instances10Eq, Ord, Show, Pretty, Dioid, MeetSemiLattice, …
Eq LabelDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverOrd LabelDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverShow LabelDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverPretty LabelDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverDioid LabelDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverMeetSemiLattice LabelDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverTop LabelDefined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverNegative 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.WarshallSolverPlus (SizeExpr' r f) Label (SizeExpr' r f)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
Convert a label to a weight, decrementing in case of Lt.
Semiring with idempotent + == dioid
0 declarationsGraphs
0 declarationsNodes
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.WarshallSolverEq 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.WarshallSolverNegative a => Negative (Edge' r f a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolverAn 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.WarshallSolverA 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
A graph forest.
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".
Add an edge to a graph forest. Graphs that share a node with the edge are joined.
Reflexive closure. Add edges 0 -> n -> n -> oo for all nodes n.
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.
Build a graph from list of simplified constraints.
Build a graph from list of simplified constraints.
Error messages produced by the solver.
If we have an edge X + n <= X (with n >= 0), we must set X = oo.
Methods
setToInfty :: [f] -> a -> a
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.WarshallSolverEq f => SetToInfty f (Edge' r f a)Defined in Agda-2.7.0.1 · Agda.TypeChecking.SizedTypes.WarshallSolver
Compute solution from constraint graph.
19 declarationsLower or upper bound for a flexible variable
Constructors
BoundslowerBounds :: Bound r fupperBounds :: Bound r fmustBeFinite :: Set fThese metas are < ∞.
Compute a lower bound for a flexible from an edge.
Compute an upper bound for a flexible from an edge.
Compute the lower bounds for all flexibles in a graph.
Compute the upper bounds for all flexibles in a graph.
Compute the bounds for all flexibles in a graph.
Compute the relative minima in a set of nodes (those that do not have a predecessor in the set).
Compute the relative maxima in a set of nodes (those that do not have a successor in the set).
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.
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.
Compute the sup of two different rigids or a rigid and a constant.
Compute the inf of two different rigids or a rigid and a constant.
Compute the least upper bound (sup).
Compute the greatest lower bound (inf) of size expressions relative to a hypotheses graph.
Solve a forest of constraint graphs relative to a hypotheses graph. Concatenate individual solutions.
Verify solution
2 declarationsCheck that after substitution of the solution, constraints are implied by hypotheses.
iterateSolver :: (Ord r, Ord f, Pretty r, Pretty f, PrettyTCM f, Show r, Show f)=> Polarities fMeta variable polarities (prefer lower or upper solution?).
-> HypGraph r fHypotheses (assumed to have no metas, so, fixed during iteration).
-> [Constraint' r f]Constraints to solve.
-> Solution r fPrevious substitution (already applied to constraints).
-> 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.