home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.object
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!uchinews!alex!dave
- From: dave@alex.uchicago.edu (Dave Griffith)
- Subject: Re: Equality
- Message-ID: <1992Dec22.183803.16421@midway.uchicago.edu>
- Sender: news@uchinews.uchicago.edu (News System)
- Organization: University of Chicago
- References: <1992Dec21.184405.2215@midway.uchicago.edu> <BzoAD8.By6@newsflash.concordia.ca>
- Date: Tue, 22 Dec 1992 18:38:03 GMT
- Lines: 49
-
- In article <BzoAD8.By6@newsflash.concordia.ca> grogono@cs.concordia.ca (Peter Grogono) writes:
- >In article <1992Dec21.184405.2215@midway.uchicago.edu> dave@alex.uchicago.edu (Dave Griffith) writes:
- >> .......
- >>1) Equality should be reflexive.
- >> I thought this was obvious, but IEEE754 may provide a counterexample.
- >>
- >>2) Equality should be symettric.
- >>3) Equality should be transitive.
- >>4) Substitution of equals for equals should give equals.
- >>5) If two objects are equal at one point in program execution, they should be
- >> equal at all points.
- >>6) Assignment should respect equality. (Assuming no side-effects, after
- >> executing x:=a; it should be true that x=a.
- >>7) If your parameter passing model is based on assignment, 6) should hold
- >> mutatis mutandi.
- >>8) If two objects are equal, they should be behaviourally indistinguishable.
- >> The converse need not hold, but often will.
- >>9) Two sets A,B are equal iff for_all(x:A)there_exists(y:B) such y=x, and
- >> vice versa.
- >>
- >>Given mutable objects, identity was the only practical definition I found
- >>which would support all of the above. However, identity is not a practical
- >>equality definition for all objects we wish to program with (vis, integers).
- >>In these cases, if immutability holds, users may be able to define equality
- >>in ways which satisfy the above, and there are good reasons to let them try.
- >
- >I do not see how "identity" supports #9. In principle, A=B, where A and
- >B are sets, should mean that A and B have the same members, even if the
- >representations of A and B are distinct in memory and may be different
- >data structures. I do not see how an equality test of this kind can be
- >built-in to a language, and this was my reason for saying that equality
- >must be user-defined in general.
- >
- >Peter
-
- Arrgh, another case of typing before thinking on my part. I was thinking
- in terms of relations and trying to come up with a way of expressing what I
- need. I failed. For all of the above to hold for set objects, they must be
- immutable anyway (#5 and #8, as well as the basic mathematical idea of set),
- and I've never expressed any disagreement with user-defined equality for
- immutable objects. If you want to test mutable "sets" to see whether they
- have the same members, but I'm not sure with calling such a test equality,
- unless equality is just another binary predicate.
-
-
- --
- Dave Griffith, Information Resources, University of Chicago,
- Department of Surgery dave@alex.bsd.uchicago.edu
- A man's best friend is his dogma.
-