Advertisement
Guest User

Untitled

a guest
Jul 8th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. x = mon (1,(0,(0,()))) :: Polynomial Integer (Natural,(Natural,(Natural,())))
  2. y = mon (0,(1,(0,()))) :: Polynomial Integer (Natural,(Natural,(Natural,())))
  3. z = mon (0,(0,(1,()))) :: Polynomial Integer (Natural,(Natural,(Natural,())))
  4.  
  5. data VARS m t where
  6.   VARZ :: VARS m ()
  7.   VARS :: (Ord n, Show n, Monoid n) => String -> VARS m n -> VARS m (m,n)
  8.  
  9. xyz = VARS "x" $ VARS "y" $ VARS "z" $ VARZ
  10. e123 = VARS "e1" $ VARS "e2" $ VARS "e3" $ VARZ
  11.  
  12. data EXISTS_VARS_AND_LOOKUP m where
  13.   WITNESS :: (Show t, Ord t, Monoid t) => t -> VARS m t -> (String -> Maybe (MonoidRing m t)) -> EXISTS_VARS_AND_LOOKUP m
  14.  
  15. declare_variables :: [String] -> EXISTS_VARS_AND_LOOKUP Natural
  16. declare_variables [] = WITNESS () VARZ (\_ -> Nothing)
  17. declare_variables (x:xs) = case declare_variables xs of
  18.   WITNESS t v f -> WITNESS (0,t) (VARS x v) (\x' -> if x == x'
  19.                                                     then Just (mon (1,t))
  20.                                                     else fmap sup (f x'))
  21.     where
  22.       sup :: Ord t => Polynomial Integer t -> MonoidRing Integer (Natural,t)
  23.       sup = fromCoefficientList . map (\(x,k) -> ((0,x),k)) . coefficientList
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement