-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Context Algebra -- @package ContextAlgebra @version 0.1.0.0 -- | models a Lattice for a context type, the top of the lattice is -- represented by One and inherits a list of all subcontexts, the bottom -- of the lattice is represented by Zero. To inherit the contextlattice -- to a new data type the data type has to instanciate: Enumerable c, Eq -- c, Ord c, Show c module ContextLattice -- | data type to represent a lattice structure, the actual context is the -- type variable c data Context c -- | constructor represents the One element of the lattice, all contexts -- are included in this constructor, for this constructor the model -- includes all contexts One :: [Context c] -> Context c -- | constructor for one context Ctx :: [c] -> Context c -- | constructor represents the bottom element of the lattice, without any -- context Zero :: Context c -- | takes a context and returns all finer getFinerContexts :: (Eq c, Enumerable c, Enumerable (Context c)) => Context c -> [Context c] -- | extracts a context list of contexts from the element, needed for the -- One wrapper constructor extractContext :: Context c -> [[c]] -- | test for commutativity -- --
--   >>> (Ctx [Walking]) `propCommutative` One [Ctx [Walking],Ctx [Driving],Ctx [Walking,Driving],Ctx [Uphill],Ctx [Walking,Uphill],Ctx [Driving,Uphill],Ctx [Walking,Driving,Uphill]] = (Ctx [Walking]) `meet` One [Ctx [Walking],Ctx [Driving],Ctx [Walking,Driving],Ctx [Uphill],Ctx [Walking,Uphill],Ctx [Driving,Uphill],Ctx [Walking,Driving,Uphill]] == One [Ctx [Walking],Ctx [Driving],Ctx [Walking,Driving],Ctx [Uphill],Ctx [Walking,Uphill],Ctx [Driving,Uphill],Ctx [Walking,Driving,Uphill]] `meet` (Ctx [Walking])
--   true
--   
propCommutative :: (Eq c, Enumerable c, Enumerable (Context c)) => Context c -> Context c -> Bool -- | test for idempotency -- --
--   >>> propIdempotent (Ctx [Walking]) = (Ctx [Walking]) `meet` (Ctx [Walking]) == (Ctx [Walking])
--   true
--   
propIdempotent :: (Eq c, Enumerable c, Enumerable (Context c)) => Context c -> Bool -- | test for associativity -- --
--   >>> propAssociative (Ctx [Walking]) (Ctx [Driving]) (Ctx [Uphill]) =  (Ctx [Walking]) `meet` ((Ctx [Driving]) `meet` (Ctx [Uphill])) == ((Ctx [Walking]) `meet` (Ctx [Driving])) `meet` (Ctx [Uphill])
--   true
--   
propAssociative :: (Eq c, Enumerable c, Enumerable (Context c)) => Context c -> Context c -> Context c -> Bool instance Show c => Show (Context c) instance Eq c => Eq (Context c) instance Ord c => Ord (Context c) instance (Enumerable c, Eq c, Enumerable (Context c)) => MeetSemiLattice (Context c) -- | This module implements the necessary functions to model a concept and -- the context influence. The concept is represented by several -- exemplars. For each influencing context the exemplars have different -- observation frequency. This conncetion is modeled here by a multiset. module Model -- | Each experience is formed by a exemplar of type e and a context c this -- exemplar was observed at. data Experience c e -- | constructor; establishes an experience from a context and an exemplar Exp :: c -> e -> Experience c e -- | All experiences are hold in a multiset type Experiences c e = MultiSet (Experience c e) -- | type synonym for better readability type Probability = Float -- | the class defines the necessary functions needed for the context -- algebra class (Ord c, Ord e, Show c, Show e) => InterpretationModel c e -- | combines the observation amount of exemplars for one context createExperiencesForContext :: (Show c, Ord c, Show e, Ord e) => c -> [e] -> [Int] -> Experiences c e -- | If an experience is made several times the amount can be specified by -- the amount manyfoldExperiences :: (Ord c, Show c, Ord e, Show e) => Experience c e -> Occur -> Experiences c e -- | calculates the amount of experiences that are present amountExperiences :: Experiences (Context c) e -> Int -- | filters experiences for a context, gets experiences for a finer -- context, the context c has to be more finer than the context that are -- included in the experiences lambda :: (Enumerable c, Enumerable (Context c), Ord e, Eq c, Ord c) => Context c -> Experiences (Context c) e -> Experiences (Context c) e -- | returns a probability of an exemplar observed in a context for the -- given experiences mu :: (Enumerable c, Enumerable (Context c), Ord e, Ord c) => Experience (Context c) e -> Experiences (Context c) e -> Probability -- | returns experiences for the exemplar given in the first argument -- e in quantum mechanics called projector filterExemplars :: (Ord c, Ord e) => e -> Experiences c e -> Experiences c e -- | returns the observation distribution for the context c, the type e is -- only used as type parameter probAllExemplars4Context :: (Ord c, Ord e, Enum e, Bounded e, Enumerable c, Enumerable (Context c)) => Context c -> e -> Experiences (Context c) e -> [(e, Probability)] -- | returns the most probable exemplar given by the list of tuples of -- (Exemplar, Probability) getMostProbableExemplar :: Ord e => [(e, Probability)] -> (e, Probability) -- | converts the experiences type to a IO() printExperiences :: (Show e, Show c) => Experiences c e -> IO () -- | adds the new experience to the given experiences addExperience :: (Ord c, Ord e) => Experience c e -> Experiences c e -> Experiences c e instance (Ord c, Ord e) => Ord (Experience c e) instance (Show c, Show e) => Show (Experience c e) instance (Eq c, Eq e) => Eq (Experience c e)