Closed jrbeaumont closed 7 years ago
Nice! But I think we should also toggle corresponding initial state bit, as well as the invariant.
I thought about this, and I agree with invariants in the chosen concept to bubble, but my issue with initial state is that you would have to include the whole concept, i.e. More than just the gate/protocol/concept you wish to bubble. This means that if you want to simply have a NAND gate, but a non-inverting C-element later on using the output of the NAND, it can become confusing, and you toggle every causality in the system.
Not sure I understand, can you give an example?
I don't see how the following doesn't work:
nAndGate a b c = bubble c $ andGate a b c
test a b c = bubble c (nAndGate a b c <> initialise0 [a, b, c])
Well I have just had a thought, and we can toggle all initial states and invariants in the given concept, which can be:
nAndGate a b c = bubble c $ andGate a b c
this will just toggle the causalities for c in the AND gate. Or we can use it as:
wholeSystem x y z = bubble z $ operation x y z <> initialise0 [x, y, z] <> never [rise y, rise z]
which will invert everything that z does.
Yes, inverting everything is the idea: it's the same as with dual
but only for one signal.
I will implement it now.
I have implemented the invariant toggles, but I cannot find a way to invert the initial state for the given signal. The implementation for dual can do it regardless of signal, because it does all initial states. For bubble, I try to use the signal to find the initial state for just this signal, but it does not work, instead throwing compilation errors however I try to do it. I also need to keep the initial states that are not for the given signal as they are.
Well, invariant
is a function that takes a signal as the input. Try to go this way:
bubbleInvariant :: Eq a => a -> (a -> InitialValue) -> (a -> InitialValue)
bubbleInvariant x f y = ...
@snowleopard There we go! All works well :)
@jrbeaumont Nice! I've added a couple of comments.
@snowleopard Fixed those issues :)
Rename done.
Thanks! Now merged.
bubble
is a concept transformation function which takes a signal and a concept andtoggle
s all of the transitions for that signal, be they cause/effect transitions in a causality, in AND/OR causalities, for the given concept. This acts as a negation on the chosen signal, be it an input or output.This serves well to provide inverting gates, for example:
These will produce a NAND gate, an OR gate with one inverted input (
a
), and an inverting output C-element, respectively.This can also be used in combination, for multiple inversions, e.g:
This will produce a NAND gate with one input (
b
) inverted.