-
Notifications
You must be signed in to change notification settings - Fork 0
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
Document equality/equivalence semantics #36
Comments
This lines up better with expectation. It is otherwise impossible for a user to create two equal (equivalent? See scijava/scijava#36) OpRefs, even if they pass the exact same Objects to the matcher
@ctrueden let's keep this in mind when looking at imagej/imagej-ops#644 |
See also related discussion on Image.sc Zulip. |
@gselzer and I spoke in more detail again about this question today. Here is what we decided, some of which I am reiterating from the Zulip thread, and some of which is new decisions made. Difference between "equality" and "equivalence": Equivalence – "In formal language theory, weak equivalence of two grammars means they generate the same set of strings, i.e. that the formal language they generate is the same. In compiler theory the notion is distinguished from strong (or structural) equivalence, which additionally means that the two parse trees are reasonably similar in that the same semantic interpretation can be assigned to both". Here, we mostly use the term "equivalence" to avoid confusion with Java's formal When it comes to op implementations, there are three kinds of equality/equivalence that occur to me, which I feel are worth discussing:
Here are the things that @gselzer and I concluded in our conversation.
A remaining question is then: what is lost by not requiring the "equal outputs" form of equivalence? Above, I claimed that it "has nice consequences, including facilitating reproducibility and caching." But does it really?
We also avoid thorny questions of what "equivalent output values" even means. Do we need output types to implement We also avoid the problems described above with ops that have the same input signature but different output type, notably the
So with that, I think this issue is resolved. I am leaving it open, though, until the Ops documentation suitably explains this design decision, and these two supported concepts of equality. For concept (2), we also probably need a better name for the "equal simplifications". Maybe "same simple signature"? |
We will want something along the lines of imagej/imagej-ops#644 in SciJava Ops, I think. We still need ops to be searchable. See this Zulip post for the difference between these |
What remains to solve this issue is to write the conclusions from this discussion into Javadoc, probably within a |
Historically, it has been a requirement of ops that two ops with the same name accepting the same inputs should produce equivalent output, where "equivalent output" means equality of content. This has nice consequences, including facilitating reproducibility and caching. However, there are questions:
It is too draconian with respect to "create" ops that implement
Source
, since two ops of the same name may return different sorts of objects that are not comparable with one another, given the same inputs (that is to say: no inputs).If you consider the output type as part of the "
OpRef
uniqueness signature" then there is no conflict, because the output types differ. We could have e.g. aLongType create()
withnames="create, create.integerType, create.longType"
andDoubleType create()
withnames="create, create.floatingType, create.doubleType
(at higher priority, so that a request for a "create" op of typeSource<T extends RealType<T>>
prefers theDoubleType
creator).However, "equality of content" is subtle and complex. Do a
LongType
and aDoubleType
have equal content if theirgetRealDouble()
methods return the same value? Do aCellImg
and anArrayImg
have equal content if they are the same type with same values and same dimensionality? Intuitively that was the idea, although it is important to note that the will not compare as equal viaequals
—those classes do not overrideequals
. This invites the possibility of additional new ops:equals
or perhapsequalContent
that tests two objects for this sort of content equality; andcompatible
or perhapsisContentComparable
that discerns whether it even makes sense to consider this question across two types.We already have
copy
computer ops that require you to specify the preallocated output object into which the content of the input will be copied. It would make sense to formally state that doingequalContent(in, out)
after callingcopy(in, out)
should always returntrue
; similarly, ifisContentComparable(in, out)
returnsfalse
then callingcopy(in, out)
should not find any ops to perform the work, since it makes no sense.My feeling is that there are many subtleties and edge cases surrounding these behaviors, so: A) these design decisions are crucial, and we need to write them down as formally as possible; and B) where feasible, we need to programmatically validate them in unit tests etc.
The text was updated successfully, but these errors were encountered: