Copyright | (c) Jesper Kuiper 2021 Leander van Boven 2021 Ramon Meffert 2021 |
---|---|
License | BSD3 |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- data GossipAtom = GAt Rel Agent Agent
- data Rel
- intToGAt :: Int -> Int -> GossipAtom
- bddToGAt :: Int -> Bdd -> [GossipAtom]
- gAtToInt :: Int -> GossipAtom -> Int
- gAtToBdd :: Int -> GossipAtom -> Bdd
- texifyGAt :: GossipAtom -> String
- texifyBddVar :: Int -> Int -> String
- data Form
- data GossipForm
- = Top
- | Atom GossipAtom
- | Neg GossipForm
- | Conj [GossipForm]
- | Disj [GossipForm]
- | Impl GossipForm GossipForm
- data GossipKnowledgeStructure = GKS (Set Int) Bdd (Map Agent (Set Int))
- vocabulary :: GossipKnowledgeStructure -> Set Int
- stateLaw :: GossipKnowledgeStructure -> Bdd
- observables :: GossipKnowledgeStructure -> Map Agent (Set Int)
- nag :: GossipKnowledgeStructure -> Int
- fromGossipGraph :: GossipGraph -> GossipKnowledgeStructure
- validKS :: GossipKnowledgeStructure -> Bool
- formToBdd :: GossipKnowledgeStructure -> Form -> Bdd
- (<|>) :: GossipKnowledgeStructure -> Form -> Bdd
- data KnowledgeTransformer = KT (Set Int) Bdd (Map Agent (Set Int))
- addVocab :: KnowledgeTransformer -> Set Int
- eventLaw :: KnowledgeTransformer -> Bdd
- addObs :: KnowledgeTransformer -> Map Agent (Set Int)
- baseTransformer :: KnowledgeTransformer
- validKT :: GossipKnowledgeStructure -> KnowledgeTransformer -> Bool
- update :: GossipKnowledgeStructure -> KnowledgeTransformer -> GossipKnowledgeStructure
- (|+|) :: GossipKnowledgeStructure -> KnowledgeTransformer -> GossipKnowledgeStructure
- updateWithCall :: GossipKnowledgeStructure -> Int -> Call -> GossipKnowledgeStructure
Atomic proposition for Dynamic Gossip
data GossipAtom Source #
An atomic proposition in a gossip state: Rel(Agent, Agent).
Instances
Eq GossipAtom Source # | |
Defined in GossipKnowledge (==) :: GossipAtom -> GossipAtom -> Bool # (/=) :: GossipAtom -> GossipAtom -> Bool # | |
Ord GossipAtom Source # | |
Defined in GossipKnowledge compare :: GossipAtom -> GossipAtom -> Ordering # (<) :: GossipAtom -> GossipAtom -> Bool # (<=) :: GossipAtom -> GossipAtom -> Bool # (>) :: GossipAtom -> GossipAtom -> Bool # (>=) :: GossipAtom -> GossipAtom -> Bool # max :: GossipAtom -> GossipAtom -> GossipAtom # min :: GossipAtom -> GossipAtom -> GossipAtom # | |
Show GossipAtom Source # | |
Defined in GossipKnowledge showsPrec :: Int -> GossipAtom -> ShowS # show :: GossipAtom -> String # showList :: [GossipAtom] -> ShowS # |
The relation type of a GossipAtom.
N | Indicates that x knows the number of y. |
S | Indicates that x knows the secret of y. |
C | Indicates that x has called y. |
Conversion to and from BDDs
intToGAt :: Int -> Int -> GossipAtom Source #
Converts a BDD variable index to a GossipAtom. Note that the first Int argument corresponds to the amount of agents present in the gossip graph. This is a bijective function to allow for unique indexing of atomic gossip propositions.
>>>
intToGAt 3 0
Naa
>>>
intToGAt 3 12
Sba
bddToGAt :: Int -> Bdd -> [GossipAtom] Source #
Converts a BDD formula to a list of GossipAtoms for all variables in the formula. Internally calls intToGAt.
>>>
bddToGAt 3 ((var 0) `imp` (var 12))
>>>
[Naa, Sba]
gAtToInt :: Int -> GossipAtom -> Int Source #
Converts a GossipAtom to a unique integer index that can be used for a BDD variable.
>>>
gAtToInt 3 (GAt S b a)
12
gAtToBdd :: Int -> GossipAtom -> Bdd Source #
Converts a GossipAtom to a unique but labelled BDD variable. Note that the first argument corresponds to the amount of agents present in the gossip graph.
>>>
gAtToBdd 3 (GAt S b a)
Sba
Note that, while this function prints the normal gossip atom, the type that is returned is of BDD instead of GossipAtom. Internally, a unique variable index has been generated.
Texification
texifyGAt :: GossipAtom -> String Source #
Converts an atomic gossip proposition into a LaTeX string.
>>>
texify (GAt N a b)
\texttt{N}ab
texifyBddVar :: Int -> Int -> String Source #
Converts a BDD variable index to a GossipAtom, and converts that to a LaTeX string.
>>>
texifyBddVar 3 12
"\texttt{S}ba"
Epistemic formulae for Dyamic Gossip
An epistemic formula, defined in terms of BDDs. This data structure allows for propositional formulae, as well as (higher-order) agent knowledge.
data GossipForm Source #
A recursively defined propositional formula build out of GossipAtoms.
Top | Always true |
Atom GossipAtom | Atom |
Neg GossipForm | Negation |
Conj [GossipForm] | Conjunction |
Disj [GossipForm] | Disjunction |
Impl GossipForm GossipForm | Implication |
Instances
Show GossipForm Source # | |
Defined in GossipKnowledge showsPrec :: Int -> GossipForm -> ShowS # show :: GossipForm -> String # showList :: [GossipForm] -> ShowS # |
Knowledge Structures for Dynamic Gossip
data GossipKnowledgeStructure Source #
A knowledge structure (Gattinger, 2018) which represents the knowledge of a Gossip State.
Instances
Eq GossipKnowledgeStructure Source # | |
Defined in GossipKnowledge | |
Show GossipKnowledgeStructure Source # | |
Defined in GossipKnowledge showsPrec :: Int -> GossipKnowledgeStructure -> ShowS # show :: GossipKnowledgeStructure -> String # showList :: [GossipKnowledgeStructure] -> ShowS # |
Knowledge Structure fields
vocabulary :: GossipKnowledgeStructure -> Set Int Source #
The set of propositional atoms available in the model.
stateLaw :: GossipKnowledgeStructure -> Bdd Source #
A boolean formula representing the law that every state needs to adhere to.
observables :: GossipKnowledgeStructure -> Map Agent (Set Int) Source #
The set of atoms seen by some agent. If an atom is observable for an agent, then they are certain as to whether this atom is true or false.
nag :: GossipKnowledgeStructure -> Int Source #
Extracts the number of agents from the Knowledge Structure.
Generation and validation
fromGossipGraph :: GossipGraph -> GossipKnowledgeStructure Source #
Converts a gossip graph to its corresponding knowledge structure. Note that this doesn't convert a gossip state, i.e. no call sequence is encoded. This is meant for the conversion of the _initial_ gossip state, (G, ε) (van Ditmarsch et al., 2017)
validKS :: GossipKnowledgeStructure -> Bool Source #
Checks if a given Knowledge Structure is valid. It checks whether the variables found in both the state law and the observable sets are present in the vocabulary.
Transition from epistemic to boolean formulae
formToBdd :: GossipKnowledgeStructure -> Form -> Bdd Source #
Converts an epistemic formula to a boolean formula, given a knowledge structure in Gattinger (2018), `fromToBdd k ϕ` is denoted by ||ϕ||_k.
(<|>) :: GossipKnowledgeStructure -> Form -> Bdd infix 9 Source #
An infix operator for the formToBdd function.
Knowledge Transformers for Dyamic Gossip
data KnowledgeTransformer Source #
The Knowledge Transformer data structure, as defined in (Gattinger, 2018).
Knowledge Transformer fields
eventLaw :: KnowledgeTransformer -> Bdd Source #
The event law.
Generation and validation
baseTransformer :: KnowledgeTransformer Source #
A base Knowledge Transformer structure, which will not change the Knowledge Structure.
validKT :: GossipKnowledgeStructure -> KnowledgeTransformer -> Bool Source #
Checks if a Knowledge Transformer is valid. Checks whether all atoms in the additional vocabulary are actually new, whether the event law only uses variables that are contained in either the original vocabulary or the additional vocabulary, and whether the additional observables are items from the additional vocabulary.
Updating Knowledge Structures
update :: GossipKnowledgeStructure -> KnowledgeTransformer -> GossipKnowledgeStructure Source #
Updates a Knowledge Structure, given a Knowledge Transformer.
(|+|) :: GossipKnowledgeStructure -> KnowledgeTransformer -> GossipKnowledgeStructure infixl 9 Source #
An infix operator for the update
function.
updateWithCall :: GossipKnowledgeStructure -> Int -> Call -> GossipKnowledgeStructure Source #
Updates a Knowledge Structure for a given call made between two agents. The integer argument denotes the tick counter.