Element-Predicate Duality
Element-predicate duality is the relationship between the elements of a thing and the predicates that can be asserted of them. Programmers use it whenever a Predicate<T>, a function T -> Bool, selects items from a collection: the predicate picks out elements, and with enough predicates it singles out one item. The relationship reads in both directions. A predicate is a function on elements, and an element is equally a function on predicates, the one that evaluates each predicate at that element:
It is an instance of duality and symmetry, and event-state duality is its most important instance in the model.
Duality as Reversal
The essence of duality is reversal. Negating real numbers reverses their order while exchanging with and floor with ceiling. Complementing a Boolean algebra reverses its order while exchanging true with false and conjunction with disjunction, which is De Morgan duality. Taking the opposite of a category reverses its arrows while exchanging limits with colimits. The third generalizes the first two, since an order is a category with an arrow from to whenever .
Element-predicate duality arises from categorical duality by choosing two objects: to serve as a singleton and to serve as truth values. For any object :
- the elements of are the arrows ;
- the predicates on are the arrows ;
- applying a predicate to an element is composition, , which yields an arrow .
The arrows form the set of truth values . Reversing the category exchanges the roles of and , so elements become predicates and predicates become elements, while stays the same and every application yields the same truth value as before. For sets the natural choice is and , which gives elements and subsets. For locally compact abelian groups the natural choice is the integers and the unit circle, which gives Pontryagin duality.
Chu Spaces
Keeping only the elements, the predicates, and the results of application gives a table. A Chu space over is a triple , where is a set of elements, is a set of predicates, and gives the value of each predicate at each element. Its dual is : the same table transposed.
Rows describe elements by the predicates they satisfy, and columns describe predicates by the elements that satisfy them. Two conditions remove redundancy:
- Extensional: no two columns are equal, so a predicate is determined by which elements satisfy it. Each predicate can then be identified with a function , and the Chu space is a pair with .
- Separable: no two rows are equal, so elements that satisfy the same predicates are the same element. This is Leibniz's identity of indiscernibles.
A biextensional Chu space is both. Biextensional Chu spaces are to Chu spaces as partial orders are to preorders: equivalent elements are identified.
Not every function need be admitted as a predicate. Which predicates are admitted is where the structure lives. A Chu space is a generalized topological space whose open sets, the admitted predicates, need not be closed under union or intersection, and whose truth values need not be two.
Morphisms
A map from to is a pair of functions in opposite directions, on elements and on predicates, such that
Elements move forward and predicates move backward. Asking whether holds after moving by is the same as asking whether held of before. When predicates are functions, . This is continuity in topology, where the inverse image of an open set is open. In programming it is the duality between state transformers and predicate transformers: a program moves states forward and pulls postconditions back to preconditions, as in Dijkstra's weakest preconditions.
Beyond Truth and Falsity
need not be Boolean. A richer records more about how an element stands with respect to a predicate. When carries the structure of a quantale, the table induces distances on both elements and predicates, and Plotkin's theorem shows that this induced structure is all the enriched structure there is. Event-state duality uses this to derive time and information from a single table.
Instances in the Model
- Event-state duality. A schedule is a Chu space with events as elements and states as predicates. An automaton is its transpose, with states as elements and events as predicates.
- Automata. The Hankel matrix of a language relates past histories to future histories by whether their concatenation is accepted. A state machine factors this table through its states, with reachability as an algebra map from histories and observability as a coalgebra map to behaviors.
- Observables. An observable is a predicate on state valued in a richer . The state is known by how it answers its observables.
- Invariants. An invariant is a predicate that every admitted state must satisfy.
- The Yoneda lemma. The Yoneda lemma characterizes an object by its relationships to all others. Element-predicate duality is its elementary form, and Lawvere distance gives its metric form.
The State-Event-Predicate Triangle
Three spaces in the model relate pairwise by element-predicate duality.
- State space, studied through state machines: the possible states of a system and the transitions among them.
- Event space, studied through processes and process calculi: the occurrences of a system and the order and choice among them.
- Predicate space, studied through assurance: the properties claimed of a system and the evidence for them.
Each side of the triangle is a table relating the elements of one space to those of another:
| Side | Table entry | Reading | Theory |
|---|---|---|---|
| States and events | has event occurred in state ? | event-state duality | automata and schedules |
| States and predicates | does state satisfy predicate ? | invariants, assertions, observables | state predicates, Hoare logic |
| Events and predicates | what must hold before for to hold after? | preconditions, trace properties | predicate transformers, temporal logic, safety and liveness |
The sides fit together. Events act on states forward as transitions and on predicates backward as predicate transformers. An invariant is preserved by event exactly when implies the weakest precondition of with respect to . A property of whole histories, such as a safety or liveness property, is a predicate on the event side, and its truth at a state depends on which events have occurred there.
Assurance also needs more than Boolean truth values. Assurance distinguishes established, conditional, refuted, and unknown claims, and warns that failure to derive a claim is not derivation of its failure. That is the distinction between not yet and never that richer draw in event-state duality, and the absence of excluded middle that Heyting algebras formalize. Predicate space is therefore naturally valued in an enriched , as event space and state space are.
Modeling Checks
- What are the elements, what are the predicates, and what are the truth values?
- Which predicates are admitted, and what structure does that choice express?
- Are elements with the same answers to every predicate treated as identical?
- Do maps move elements forward and pull predicates back consistently?
- Is a Boolean answer enough, or must unknown, partial, or graded answers be kept distinct?
Formal relations
refines: Duality and Symmetry — Gives the general duality between elements and predicates, of which event-state duality and the state-event-predicate triangle are instances.
External References
- Vaughan R. Pratt, Event-State Duality: The Enriched Case, CONCUR 2002, LNCS, 41-56, Section 2. PDF
- Vaughan R. Pratt, Chu Spaces as a Semantic Bridge between Linear Logic and Mathematics, Theoretical Computer Science 294(3):439-471, 2003.
- Michael Barr, *-Autonomous Categories, Lecture Notes in Mathematics 752, Springer, 1979.
- Edsger W. Dijkstra, Guarded Commands, Nondeterminacy and Formal Derivation of Programs, Communications of the ACM 18(8):453-457, 1975.
- Michael B. Smyth, Power Domains and Predicate Transformers: A Topological View, ICALP 1983, LNCS 154, 662-675.