New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prefer functions as strategies, instead of transducers with internal state #147
Comments
Can you distill design recommendations from your opening post for us? What would be sufficient for closing the issue? Otherwise, your text might be better placed in a venue for discussion separate from the code, such as the mailing list. Some of your comments are interesting, and I would respond and engage in discussion, but I do not think the issue tracker is appropriate. |
We could also try to use a different platform than the mailing list. I would recommend Discourse. |
Functions to represent strategiesFunctions in codeThe main change would be to represent the synthesized strategies as mathematical functions.
I plan to experiment with these in I do not favor classes, because a So, the method of a class may serve better this purpose. Miscellaneous benefits that come with a class are:
I don't expect the first experiment in this direction to be the final solution. But it would be a starting point to see what is more practical to use. Interleaving or notIf noninterleaving representations are synthesized and simulated, then, in general, a turn-based game requires that players be asymmetric. For 2 players this means that player 0 should be "Moore" (read For these reasons, I am reluctant to work with the noninterleaving currently used in Making memory explicitAnother change implied by using mathematical functions (no magic state inside them) is that the transducer's memory will need to be explicitly defined by the synthesizer. The variables About the simplicity of functions, and the benefits of making any state visible to users (that may be students), I think that a similar argument applies as "Mathematical functions are simple; ... Pascal functions are complicated..." on p.873 of "The temporal logic of actions", with "Mealy machines" in the role of Pascal functions (both involve some state invisible to the user). Representation with interleaving behaviorsA system can be represented in logic with interleaving or without. A behavior is interleaving if in no step any changes to variable values are attributed to more than one player. Interleaving specifications are introduced on p.137 of "Specifying systems" by Lamport. I was writing non-interleaving specifications (common in the GR(1) literature), until the mistakes that resulted from priming nuances and asymmetry between environment and system convinced me that I should not trust specifications written in this way. Abadi and Lamport write in "Conjoining specifications", p.515: "We have found that, in TLA, interleaving representations are usually easier to write and to reason about. Moreover, an interleaving representation is adequate for reasoning about a system if the system is modeled at a sufficiently fine grain of atomicity." A list of advantages that interleaving specifications enjoy (not exhaustive):
Who owns the scheduling variable ?Finally, there is a detail worth noting that also came up in discussion: an interleaving representation may or may not be perfectly interleaving, depending on who "owns" the scheduling variable that signifies who's "moving next". If the same player controls this variable throughout, then the game is still non-interleaving. But it is non-interleaving due to only this variable (that serves as a digital clock). With respect to the rest of the variables, the representation is interleaving. If the scheduling variable changes owner (a shared-state representation), then an interleaving representation results, which is not disjoint-state any more. I don't think that the formal definition of "interleaving" and what a single variable does should distract us from the benefits of what the rest of the variables are doing, making a specification "interleaving in essence". |
I would prefer if interleaving is not the only option. It makes sense for "board games" or software but for anything physical, it is not reasonable to expect that you can freeze the dynamics of a system until the environment moves and vice versa. I prefer to use Moore synthesizers for hybrid problems. |
Can you say a bit more abou how you are imagining to use functions for control strategies that require memory? I can imagine a function that takes as input all the history up to that point in time, so input is a sequence with unspecified length but this does not sound like a good idea (states make the memory rep. more compact). |
Having both is possible. My interest is mainly in implementing the interleaving one. Taking the above arguments and previous discussion into account, I would expect that a noninterleaving representation would be used in simpler problems that are one-sided (not compositional, and perhaps with only a system synthesized). That case seems simpler to implement, because it doesn't need a Moore synthesizer (the winning set computation using a Moore synthesizer doesn't differ much, it is already implemented, but I expect that the strategy construction will need some existential quantification to eliminate For the sake of investigation and comparison, implementing both would be a prerequisite for making a comparison in practice. |
About the freezing of dynamics, I think that this is a matter of identifying passage of physical time with steps between consecutive states in a behavior (a sequence that models a temporal logic formula). It is an issue that needs to be discussed. Using stutter-sensitive specifications, the usual approach is to let steps correspond to passage of physical time (in discrete jumps). But that is not necessary. Still with a stutter-sensitive specification, we can let another (agreed) number of steps correspond to physical time. In particular, in an interleaving representation, 2 time steps can be understood as 1 discrete physical time step. This leaves us with deciding how the physical world is going to evolve "at the same time". There are at least two alternatives:
I think that No.2 is a better choice, because it doesn't introduce any additional variables, and it minimally affects the specification. Also, it is just another way to write the existing, noninterleaving specifications, as has already been remarked in other discussion. It may seem somewhat unnatural to require that a property hold only at certain states in a behavior, but that is already the case in noninterleaving specifications. When both players move in one time step, the "middle states" do exist in the game, but don't appear in the logic. So, the information flow isn't as evident. This can make a difference, if, together with the physical variables, there are also computing signals that do participate in intermediate states, because of their much higher frequency (see also comment below). By using an interleaving representation, we force ourselves (and students) to ask these questions, and apply invariants though all time (both In relation to the quote above from Abadi and Lamport, such a specification expresses things with a finer grain of atomicity, and in so doing "magnifies" what is happening, making it easier to read and understand the information flow. To connect with the literature, specifications like those we are discussing, where time plays a role, are called real time specifications. Disassociating logic steps from physical time accommodates also for separation of time scales (as in singular perturbation theory) and refinement. Comment on efficiency of implementationIt should be noted that my suggestion is targeting mainly how users write specifications. Using an extra variable |
I prefer Moore players too. But a noninterleaving game with Moore players is concurrent. We can still synthesize for GR(1) properties with a Moore synthesizer. Arguably, it could also be more realistic. But what a concurrent game really is is a game with partial information. This can be emphasized more in an interleaving representation with explicit hiding. A concurrent game is not determined, meaning that if a player cannot win, then this doesn't imply that the opponent can win for the negated property as objective. If we want to work with a turn-based game and Moore players, then I think that the representation will have to be interleaving. The only exception is the scheduling variable, if a disjoint-state representation is desired. Then, the game is concurrent, but because the scheduling variable changes in a deterministic way (it is a history variable), it can be proved that the game is equivalent to a "Mealy" game, and thus encoded and solved with an existing solver (like Side comment: a Moore system with a Mealy environment is subject to the same issues as a Mealy system with a Moore environment, if we are interested in synthesizing both, and still require reasoning about asymmetrically primed specifications. |
The question of what argument is given to a function that represents a strategy is a good point, because at least two approaches are commonly encountered in the literature:
I propose No.2, which is also what is used (informally as prose mixed with math) in the definition of GR(1) synthesis on p.915 of "Synthesis of reactive(1) designs". I would like to point out that, as written, No.1 and No.2 are the same, because
No.2 is realistic, because it involves the current state only, and the extra memory requirements take the form of what type invariant holds for No.2 is also what is already used, for example in For a Mealy player, For Moore players, A remark that feeding |
Relevant to #146. |
Also, it may be useful to contrast the state-space based approach using functions (and the explicit quantification of initial states that will accompany it) to how long (and confusing) the discussion was in (the otherwise very useful) #93. |
Also, this way of simulating things is the simplest loop that a one may write to integrate a system of differential equations. The user just needs to be told what extra variables appeared (the various memories, for tracking goals or remembering past values, e.g., because past temporal operators were used) when the strategy was synthesized. API calls can be provided for this purpose, it doesn't have to happen entirely manually. |
No.1 above is a controller; No.2 above is a controller state update function. Consider you have a simple not-memoryless controller of the form (could be a PID controller - btw, control is usually an upper level class, junior year so no freshmen :-))
What you describe in No. 2 is f here. It is not the controller. Any control implementation will need to store the state explicitly. Remembering the history as in No.1 requires infinite memory so not physically possible. Might be easier to return |
I agree that the value of variable Returning I agree that There is a mismatch though between what is called strategy in the literature, and what the implementor would call the controller, and mean all the parts that make the controller, thus including both
We could decide to call the update function I mentioned the unbounded- In No.2, if Interestingly, that |
By "call" I mean in terminology, not in code. We could call it |
Re interleaving: I think non-interleaving semantics are better suited to one of the default problems in TuLiP (given hybrid system, discrete env., spec, design a controller) so I would prefer to keep Mealy or Moore solvers as default. For me, asymmetry is fine as long as you give more power to things you do not control (i.e., environment) if you want to be "robust". In general, in hybrid problems, one might even assume the system has delayed observations (though env. is superior/smart/clairvoyant and observes everything instantaneously) and solve for a delay-tolerant controller with proper reformulation to obtain an equivalent Moore or Mealy synthesis problem. Though such reformulations can be done outside the main solver to be explicit. I agree that symmetry makes sense when dealing with multi-agent control and distributed settings to give "equal power" to all agents involved. But still if there is anything for which one does not design a controller, it can be assumed to be superior (an environment for the multiple agents; not the "environment" for individual ones). As for interleaving semantics, it is convenient for (i) proving things in distributed, multi-agent settings, (ii) simulating distributed, multi-agent systems. But I believe it is hard to impose interleaving when physical processes are involved so might be far from reality when physics is involved. Maybe there are proper reformulations to get other type of orderings in games even the default solver assumes interleaving but having it as default might not be the best option for hybrid systems. |
I have been thinking about a suggestion by @necozay to use a Moore system, but let the environment be Mealy. I still think that it would be good to have a symmetric formulation, with both players being Moore machines. After thinking about these, it seems that we can have a single solution that serves all purposes. I describe this below. Summary
So, we can assume a concurrent game with Moore players, and write noninterleaving or interleaving specs as desired. Since non-compositional work doesn't touch the environment, this lets noninterleaving specs be used for it. But symmetry is ensured (which turns out to be decoupled from interleaving, in this case). Determinacy is lost, but, who relied on determinacy? (see also comment below about counter-strategies as debugging aid). Conversely, if anyone would like to specify a more complex, bidirectional interaction with the environment, then they probably want to write an interleaving spec. They can still choose to write a noninterleaving one, but most likely they'd like to work with Moore machines, since these will represent engineered components. Mealy players could be included as an option, though the previous observations seem to render them obsolete. DetailsTerminologyBefore continuing, a few informal definitions / summarizing notes:
Symmetry: everyone Moore is conservative, so goodThe key point is that the environment being Moore is about what it can accomplish, not about how much the system can accomplish. In other words, if we give less power to the environment regarding what can be written in the assumption, then this means that we can assume less. It doesn't give less power to the opponent, because the opponent is the universal quantifier, not the assumption. The universal quantifier for the system already is pessimistic enough. So, a "Moore" assumption doesn't make things easier for the system. It makes them more difficult. I know that this sounds counter-intuitive, but that's the case. A simple way to see this, is to think about what happens if env can see Interleaving is a separate concernThis leaves interleaving / non-interleaving as a separate choice. Taking into account that well-separated environments and non-compositional problems (as is most of what The universal quantifier is still as powerful an adversary as a Mealy environment would be, so this does not help the system in any way. The only thing that changes is that one shouldn't refer to General APIGoing a step further, any game can be supported, by asking for a suitable definition to be given. The definition should contain what capabilities each player (sys, env, etc.) has, i.e., whether the player's strategy
About the environment being Mealy: I definitely agree that it is better to be pessimistic about what env can do. But, as discussed below, this pessimism is already present due to the universal quantifier. It is better to assume that the environment, too, is Moore, because that prevents us from asking from the environment things that it cannot do. Since the specs where this matters are compositional, involve cooperation between env and sys, and will likely involve synthesizing both sides, I think that in those cases one would probably choose to keep a Moore environment, and write an interleaving spec. They could also choose a Mealy environment and write a non-interleaving spec. In any case, supporting both interleaving and non-interleaving synthesis is a matter of definition. Those interested in synthesizing counter-strategies as an aid to understand why synthesis failed should still synthesize a Mealy environment. But, that environment is fictitious: it is a manifestation of the workings of the universal quantifier (like a ghost), not of an engineered component. |
The previous is essentially about the gap between the universal quantifier, and what the environment can be assumed to be capable of. This gap is what makes a game determined or not. Rephrased, a Moore env is about what behaviors we can exclude via an assumption in our spec. It is about how much we can ask from the opponent (the universal quantifier), but not about how much the opponent can do against us (which remains unchanged). |
About the comment above regarding interleaving specs that represent physical processes. Yes, physical processes can be described by interleaving specifications, equivalently to how they can be described with noninterleaving specifications. The way to achieve this is by means of an auxiliary variable that "slices" states in a behavior, selecting some of them (those at time increments). The resulting spec looks something like |
At the risk of jumping into a conversation that I don't completely follow, one thought on the use of functions to encode controllers (really the update law): one of the reasons that this might be useful is that you could, in principle, use the current state for the memory instead of the expected state. This is roughly what happens in traditional control systems: we don't assume that the state evolves according to the model that we used for synthesis, but rather read the state (often through an estimate) and send that to the update function. Of course, the controller can also have internal state (like a dynamic compensator), which would correspond to the case were part only part of the memory is updated based on measurements. |
Switching to a function representation seems reasonable. Couple of things:
|
Good points. I think we definitely want to maintain the current capability to generate automata, in addition to enabling the output be in the form of a function. |
Details of function representation
Keeping and deleting codeI agree that the current code can stay where it is, until the replacements make it obsolete. At that point it may be better to either delete it or move it at a different place. In any case, constructing a state machine of some form, possibly annotated with quantification (in the form of liveness) should definitely remain. My preference is for symbolic representation, because it works for any problem that synthesis worked (enumerated state machines work only for small problems). Even with the functions suggested in this feature, packaging the function together with its memory for use by others requires a suitable data structure. It may also arise for simulation purposes, like a "breadboard" where one registers and connects functions and memories. There are also a few other points. (Semi-)enumerated and symbolic representations of state machines will remain in one form or another, because they enable representation of problem input. The semi-enumerated ones currently available are in I support the latter in favor of the former, because it is a rewrite that drops unnecessary, ill-designed, or defunct features, uses little code (one file, fewer bugs). It doesn't contain most of the things in Likewise, the 900 hundred lines I've written in On the side of logic, About symbolic representation, The API of all these changes, relatively slowly. |
I bumped the target milestone for this issue, again, because the amount of remaining work to address this issue may be large, whereas there are other improvements on |
Functions are what is synthesized.
Functions are simple.
Functions are flat, because no state is nested inside them.
Functions are explicit, because all state is outside, visible to the user, who is responsible for the "wiring".
Functions are easy to use in simulation.
Functions are local, because they need to be called only when the corresponding player moves.
Transducers are an I/O construct, with the associated drawbacks of an I/O viewpoint (as opposed to state space).
Transducers are global: they maintain implicitly foreign state internally (environment state). This is harmful to simulation, and away from reality. In reality, that state is another part of the world.
Plugging together Mealy transducers results in an unnatural system that, in general, requires solving a (centralized) fixpoint to find the next state. This is not a distributed system. No more than one component can be designed this way, unless we are working with synchronous circuits and are prepared to synthesize both Mealy and Moore machines.
The text was updated successfully, but these errors were encountered: