addEPDomVarDeclToSig :: Sign -> Token -> APInt -> Sign
addEPDomVarDeclToSig sig tok i = sig {epvars = ev'}
    where ev' = Map.insertWith f tok (Just i) $ epvars sig
          f _ (Just x) 
              | x == i = error $ "addEPDomVarDeclToSig: equal values for "
                         ++ show tok
              | otherwise = error $ "addEPDomVarDeclToSig: variable already"
                            ++ " set to different value " ++ show tok ++ "="
                            ++ show x
          f n _ = n

-- | Adds an extended parameter declaration for a given domain and
-- eventually implicitly defined EP domain vars, e.g., for 'I = [0, n]'
-- 'n' is implicitly added
addEPDomVarDeclToSig :: Sign -> Token -> APInt -> Sign
addEPDomVarDeclToSig sig tok i = sig {epvars = ev'}
    where ev' = Map.insertWith f tok (Just i) $ epvars sig
          f _ (Just x) 
              | x == i = error $ "addEPDomVarDeclToSig: equal values for "
                         ++ show tok
              | otherwise = error $ "addEPDomVarDeclToSig: variable already"
                            ++ " set to different value " ++ show tok ++ "="
                            ++ show x
          f n _ = n

-- | Adds an extended parameter declaration for a given domain and
-- eventually implicitly defined EP domain vars, e.g., for 'I = [0, n]'
-- 'n' is implicitly added
addEPDomVarDeclToSig sig tok i = sig {epvars = ev'}
    where ev' = Map.insertWith f tok (Just i) $ epvars sig
          f _ (Just x) 
              | x == i = error $ "addEPDomVarDeclToSig: equal values for "
                         ++ show tok
              | otherwise = error $ "addEPDomVarDeclToSig: variable already"
                            ++ " set to different value " ++ show tok ++ "="
                            ++ show x
          f n _ = n

-- | Adds an extended parameter declaration for a given domain and
-- eventually implicitly defined EP domain vars, e.g., for 'I = [0, n]'
-- 'n' is implicitly added