问题描述
在阅读数学和计算机科学时,我已经阅读了一些使用等价符号 ≡
(基本上是三行的'=')的实例,读这就像平等.这两个概念有什么区别?
I've read a few instances in reading mathematics and computer science that use the equivalence symbol ≡
, (basically an '=' with three lines) and it always makes sense to me to read this as if it were equality. What is the difference between these two concepts?
推荐答案
等价关系〜"是自反,对称和可传递的.
An equivalence relation "~" is reflexive, symmetric, and transitive.
换句话说,=只是等价关系的一个实例.
In other words, = is just an instance of equivalence relation.
编辑:自反,对称和可传递的看似简单的标准并不总是琐碎的.请参见Bloch的有效Java第二版.例如35
Edit: This seemingly simple criteria of being reflexive, symmetric, and transitive are not always trivial. See Bloch's Effective Java 2nd ed p. 35 for example,
public final class CaseInsensitiveString {
...
// broken
@Override public boolean equals(Object o) {
if (o instance of CaseInsensitiveString)
return s.equalsIgnoreCase(
((CaseInsensitiveString) o).s);
if (o instanceof String) // One-way interoperability!
return s.equalsIgnoreCase((String) o);
return false;
}
...
}
上面的equals实现破坏了对称性,因为CaseInsensitiveString
知道String
类,但是String
类不知道CaseInsensitiveString
.
The above equals implementation breaks the symmetry because CaseInsensitiveString
knows about String
class, but the String
class doesn't know about CaseInsensitiveString
.
这篇关于平等与对等有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!