module Karttunen2 where import Finite import Pretty import qualified Data.Set as S -- There are three individuals in the domain: Alice, Bob, and Carol. data E = Alice | Bob | Carol deriving (Eq, Ord, Enum, Bounded, Show, Read) instance Finite E where everything = enumEverything cardinality = enumCardinality instance Pretty E -- Because we are only concerned with the seeing relation, we simply take -- a possible world to be a set of seer-seen pairs. type World = E -> E -> Bool -- A proposition is a set of possible worlds. type Prop = World -> Bool -- The transitive verb "saw" takes two arguments: the seen and the seer. saw :: World -> E -> E -> Bool saw w seen seer = w seer seen -- Karttunen's extension for the question "Who did Alice see?": the set of -- true answers. q :: World -> S.Set Prop q w = S.filter (\prop -> prop w) (S.fromList [\w' -> saw w' Alice Alice, \w' -> saw w' Bob Alice, \w' -> saw w' Carol Alice]) -- The real world. reality :: World reality seer seen = seer == Alice && seen == Alice || seer == Alice && seen == Bob || seer == Bob && seen == Bob || seer == Bob && seen == Carol