Class World
Defined in File World.h
Class Documentation
-
class World
A class to represent an assignment of boolean values to propositions. A World can be partially restrictive, i.e., some propositions do not have to be assigned a value, in which case it can take on any value. Our notion of a World is similar to a set of truth assignments in propositional logic.
Public Functions
-
World(unsigned int numProps)
Initializes a world with a given number of propositions.
-
bool operator[](unsigned int i) const
Returns the boolean value of a given proposition in this World. Reports an error if the proposition has not set in this World.
-
bool &operator[](unsigned int i)
Returns the boolean value of a given proposition in this World. Creates a boolean value for the proposition if one does not already exist.
-
unsigned int numProps() const
Returns the number of propositions declared for this World. Not all of the propositions have necessarily been set.
-
bool satisfies(const World &w) const
Returns whether this World propositionally satisfies a given World w. Specifically, returns true iff for every proposition p assigned in w, p is assigned in this World and this[p] == w[p].
-
std::string formula() const
Returns a formatted string representation of this World, as a conjunction of literals.
-
const std::unordered_map<unsigned int, bool> &props() const
Returns this World’s underlying proposition-to-boolean assignment map.
-
bool operator==(const World &w) const
Returns whether this World is equivalent to a given World, by comparing their truth assignment maps.
-
void clear()
Clears this world’s truth assignment.
Friends
- friend struct std::hash< World >
-
World(unsigned int numProps)