# Partial equivalence relation

In mathematics, a partial equivalence relation (often abbreviated as PER, in older literature also called restricted equivalence relation) is a homogeneous binary relation that is symmetric and transitive. If the relation is also reflexive, then the relation is an equivalence relation.

## Definition

Formally, a relation $R$ on a set $X$ is a PER if it holds for all $a,b,c\in X$ that:
* if $aRb$, then $bRa$ (symmetry)
* if $aRb$ and $bRc$, then $aRc$ (transitivity)
Another more intuitive definition is that $R$ on a set $X$ is a PER if there is some subset $Y$ of $X$ such that $R\subseteq Y\times Y$ and $R$ is an equivalence relation on $Y$. The two definitions are seen to be equivalent by taking $Y=\{x\in X\mid x\,R\,x\}$.

## Properties and applications

The following properties hold for a partial equivalence relation $R$ on a set $X$:
* $R$ is an equivalence relation on the subset $Y=\{x\in X\mid x\,R\,x\}\subseteq X$.
* difunctional: the relation is the set $\{(a,b)\mid fa=gb\}$ for two partial functions $f,g:X\rightharpoonup Y$ and some indicator set $Y$
* right and left Euclidean: For $a,b,c\in X$, $aRb$ and $aRc$ implies $bRc$ and similarly for left Euclideanness $bRa$ and $cRa$ imply $bRc$
* quasi-reflexive: If $x,y\in X$ and $xRy$, then $xRx$ and $yRy$.
None of these properties is sufficient to imply that the relation is a PER.

### In non-set-theory settings

In type theory, constructive mathematics and their applications to computer science, constructing analogues of subsets is often problematic—in these contexts PERs are therefore more commonly used, particularly to define setoids, sometimes called partial setoids. Forming a partial setoid from a type and a PER is analogous to forming subsets and quotients in classical set-theoretic mathematics.
The algebraic notion of congruence can also be generalized to partial equivalences, yielding the notion of subcongruence, i.e. a homomorphic relation that is symmetric and transitive, but not necessarily reflexive.

## Examples

A simple example of a PER that is not an equivalence relation is the empty relation $R=\emptyset$, if $X$ is not empty.

### Kernels of partial functions

If $f$ is a partial function on a set $A$, then the relation $\approx$ defined by
    $x\approx y$ if $f$ is defined at $x$, $f$ is defined at $y$, and $f(x)=f(y)$
is a partial equivalence relation, since it is clearly symmetric and transitive.
If $f$ is undefined on some elements, then $\approx$ is not an equivalence relation. It is not reflexive since if $f(x)$ is not defined then $x\not \approx x$ — in fact, for such an $x$ there is no $y\in A$ such that $x\approx y$. It follows immediately that the largest subset of $A$ on which $\approx$ is an equivalence relation is precisely the subset on which $f$ is defined.

### Functions respecting equivalence relations

Let X and Y be sets equipped with equivalence relations (or PERs) $\approx _{X},\approx _{Y}$. For $f,g:X\to Y$, define $f\approx g$ to mean:
    $\forall x_{0}\;x_{1},\quad x_{0}\approx _{X}x_{1}\Rightarrow f(x_{0})\approx _{Y}g(x_{1})$
then $f\approx f$ means that f induces a well-defined function of the quotients $X/{\approx _{X}}\;\to \;Y/{\approx _{Y}}$. Thus, the PER $\approx$ captures both the idea of definedness on the quotients and of two functions inducing the same function on the quotient.

### Equality of IEEE floating point values

The IEEE 754:2008 standard for floating-point numbers defines an "EQ" relation for floating point values. This predicate is symmetric and transitive, but is not reflexive because of the presence of NaN values that are not EQ to themselves.