-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Unification in a Commutative Monoid -- -- The unification problem is given the problem statement t =? t', find a -- most general substitution s such that s(t) = s(t') modulo the axioms -- of a commutative monoid. Substitition s is more general than s' if -- there is a substitition s" such that s' = s" o s. @package cmu @version 1.3 -- | Homogeneous Linear Diaphantine Equation solver. -- -- The solver uses the algorithm of Contejean and Devie as specified by -- David Papp and Bela Vizari in "Effective Solutions of Linear -- Diophantine Equation Systems with an Application to Chemistry", Rutcor -- Research Report RRR 28-2004, September, 2004, -- http://rutcor.rutgers.edu/pub/rrr/reports2004/28_2004.ps, after -- modification so as to ensure every basis vector is considered. -- -- The algorithm for systems of homogeneous linear Diophantine equations -- follows. Let e[k] be the kth basis vector for 1 <= k <= n. To -- find the minimal, non-negative solutions M to the system of equations -- sum(i=1,n,a[i]*v[i]) = 0, the algorithm of Contejean and Devie is: -- --
    --
  1. [init] A := {e[k] | 1 <= k <= n}; M := {}
  2. --
  3. [new minimal results] M := M + {a in A | a is a solution}
  4. --
  5. [unnecessary branches] A := {a in A | all m in M : some 1 <= k -- <= n : m[k] < a[k]}
  6. --
  7. [test] If A = {}, stop
  8. --
  9. [breadth-first search] A := {a + e[k] | a in A, 1 <= k <= n, -- <sum(i=1,n,a[i]*v[i]),v[k]> < 0}; go to step 2
  10. --
module Algebra.CommutativeMonoid.HomLinDiaphEq -- | The homLinDiaphEq function takes a list of integers that -- specifies a homogeneous linear Diophantine equation, and returns the -- equation's minimal, non-negative solutions. homLinDiaphEq :: [Int] -> [[Int]] -- | This module provides unification in a commutative monoid. -- -- In this module, a commutative monoid is a free algebra over a -- signature with two function symbols: -- -- -- -- The algebra is generated by a set of variables. Syntactically, a -- variable is an identifer such as x and y (see isVar). -- -- The axioms associated with the algebra are: -- -- -- -- A substitution maps variables to terms. A substitution s is applied to -- a term as follows. -- -- -- -- The unification problem is given the problem statement t =? t', find a -- most general substitution s such that s(t) = s(t') modulo the axioms -- of the algebra. Substitition s is more general than s' if there is a -- substitition s" such that s' = s" o s. module Algebra.CommutativeMonoid.Unification -- | A term in a commutative monoid is represented by the identity element, -- or as the sum of factors. A factor is the product of a positive -- integer coefficient and a variable. No variable occurs twice in a -- term. For the show and read methods, zero is the identity element, the -- plus sign is the moniod operation. data Term -- | ide represents the identity element (zero). ide :: Term -- | A variable is an alphabetic Unicode character followed by a sequence -- of alphabetic or numeric digit Unicode characters. The show method for -- a term works correctly when variables satisfy the isVar -- predicate. isVar :: String -> Bool -- | Return a term that consists of a single variable. var :: String -> Term -- | Multiply every coefficient in a term by an non-negative integer. mul :: Int -> Term -> Term -- | Add two terms. add :: Term -> Term -> Term -- | Return all variable-coefficient pairs in the term in ascending -- variable order. assocs :: Term -> [(String, Int)] -- | An equation is a pair of terms. For the show and read methods, the two -- terms are separated by an equal sign. newtype Equation Equation :: (Term, Term) -> Equation -- | A substitution maps variables into terms. For the show and read -- methods, the substitution is a list of maplets, and the variable and -- the term in each element of the list are separated by a colon. data Substitution -- | Construct a substitution from a list of variable-term pairs. subst :: [(String, Term)] -> Substitution -- | Return all variable-term pairs in ascending variable order. maplets :: Substitution -> [(String, Term)] -- | Return the result of applying a substitution to a term. apply :: Substitution -> Term -> Term -- | Given Equation (t0, t1), return a most general substitution s -- such that s(t0) = s(t1) modulo the equational axioms of a commutative -- monoid. unify :: Equation -> Substitution instance Eq Maplet instance Eq Substitution instance Eq Equation instance Eq Term instance Read Substitution instance Show Substitution instance Read Maplet instance Show Maplet instance Read Equation instance Show Equation instance Read Term instance Show Term