tulip-control / dd

Binary Decision Diagrams (BDDs) in pure Python and Cython wrappers of CUDD, Sylvan, and BuDDy
https://pypi.org/project/dd
Other
181 stars 39 forks source link

consider renaming `add_var` to `declare` #25

Closed johnyf closed 7 years ago

johnyf commented 7 years ago

Methods and functions that change state should preferably have a verb as name. "add_var" isn't a verb. It's not even an English word. To what are we "adding"?

Strictly speaking, we are extending a formal system by a definition of a nullary operator name. We call a nullary operator a "variable". In any given interpretation, the operator is applied to no arguments, yielding a value (for variables in BDD.vars, it so happens that we always reason about models that assign to the variables values in the set BOOLEAN in TLA+). For example, the operator "x" is applied to yield "x()". For brevity, we never write the empty parentheses.

In Python, "add" is used mostly for unordered containers, with set as a prototype. I named the method add_var after networkx conventions. In networkx though, adding nodes and edges makes more sense for a graph as a collection of containers. It is awkward to conceptualize a BDD as a container of variables.

Practicality:

Readability:

johnyf commented 7 years ago

Addressed by ac9f32927c69e1f474fc2df018ed042479e9bf2d, d496963136c345d15b55c35c4e3d869cf3b3bc35. The method BDD.add_var has been kept. Instead of deprecating and removing it, declare iteratively calls add_var. The usefulness of add_var is that it allows for more detailed information to be passed (for now a desired level for the variable being declared). The method add_var could remain as is, or be hidden in the future.