平等与对等有什么区别? [英] What is the difference between equality and equivalence?

查看:497
本文介绍了平等与对等有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读数学和计算机科学时,我已经阅读了一些使用等价符号 (基本上是三行的'=')的实例,读这就像平等.这两个概念有什么区别?

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?

推荐答案

维基百科:等效关系 :

在数学中,等价 关系是之间的二元关系 一组的两个元素 他们一起被认为是等价的" 某种方式.设a,b和c为任意 某个集合X的元素.然后是"a〜b" 或"a≡b"表示a为 等同于b.

In mathematics, an equivalence relation is a binary relation between two elements of a set which groups them together as being "equivalent" in some way. Let a, b, and c be arbitrary elements of some set X. Then "a ~ b" or "a ≡ b" denotes that a is equivalent to b.

等价关系〜"是自反,对称和可传递的.

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.

这篇关于平等与对等有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆