\import{relation.tex}
\import{relation/properties.tex}

\subsection{Quasiorders}

% also called preorder
\begin{abbreviation}\label{quasiorder}
    $R$ is a quasiorder iff
    $R$ is quasireflexive and transitive.
\end{abbreviation}

% also called preorder
\begin{abbreviation}\label{quasiorder_on}
    $R$ is a quasiorder on $A$ iff
        $R$ is a binary relation on $A$ and
        $R$ is reflexive on $A$ and transitive.
\end{abbreviation}

\begin{struct}\label{quasiordered_set}
    A quasiordered set $X$ is a onesorted structure
    equipped with
        \begin{enumerate}
            \item $\lt$
        \end{enumerate}
    such that
    \begin{enumerate}
        \item\label{quasiorder_type} $\lt[X]$ is a binary relation on $\carrier[X]$.
        \item\label{quasiorder_refl} $\lt[X]$ is reflexive on $\carrier[X]$.
        \item\label{quasiorder_tran} $\lt[X]$ is transitive.
    \end{enumerate}
\end{struct}

\begin{lemma}\label{quasiorder_transitive_double}
    Let $X$ be a quasiordered set.
    Let $a, b, c, d \in X$.
    Suppose $a\mathrel{\lt[X]} b\mathrel{\lt[X]} c\mathrel{\lt[X]} d$.
    Then $a\mathrel{\lt[X]} d$.
\end{lemma}
\begin{proof}
    $\lt[X]$ is transitive by \cref{quasiorder_tran}.
    Thus $a\mathrel{\lt[X]} c\mathrel{\lt[X]} d$ by \cref{transitive}.
    Hence $a\mathrel{\lt[X]} d$ by \cref{transitive}.
    Follows by assumption.
\end{proof}

\begin{proposition}\label{subseteqrel_is_quasiorder}
    $\subseteqrel{A}$ is a quasiorder on $A$.
\end{proposition}
\begin{proof}
    Show for all $w\in\subseteqrel{A}$ we have $w\in A\times A$.
    \begin{subproof}
        Fix $w$.
        Assume $w\in\subseteqrel{A}$.
        Take $a,b$ such that $w=(a,b)$ and $a,b\in A$
            by \cref{subseteqrel,pair_eq_iff}.
        Follows by \cref{times_tuple_intro}.
    \end{subproof}
    Thus $\subseteqrel{A}$ is a binary relation on $A$
        by \cref{subseteq}.
    $\subseteqrel{A}$ is reflexive on $A$
        by \cref{reflexive_on,subseteqrel,subseteq}.
    Show for all $a,b,c$ such that
        $a\mathrel{\subseteqrel{A}}b$ and
        $b\mathrel{\subseteqrel{A}}c$
        we have $a\mathrel{\subseteqrel{A}}c$.
    \begin{subproof}
        Fix $a,b,c$.
        Assume $a\mathrel{\subseteqrel{A}}b$ and
            $b\mathrel{\subseteqrel{A}}c$.
        Take $x,y$ such that $(a,b)=(x,y)$ and
            $x,y\in A$ and $x\subseteq y$ by \cref{subseteqrel}.
        Then $a=x$ and $b=y$ by \cref{pair_eq_iff}.
        Thus $a\subseteq b$ and $a\in A$ by assumption.
        Take $u,v$ such that $(b,c)=(u,v)$ and
            $u,v\in A$ and $u\subseteq v$ by \cref{subseteqrel}.
        Then $b=u$ and $c=v$ by \cref{pair_eq_iff}.
        Thus $b\subseteq c$ and $c\in A$ by assumption.
        Thus $a\subseteq c$ by \cref{subseteq_transitive}.
        Follows by \cref{subseteqrel}.
    \end{subproof}
    Thus $\subseteqrel{A}$ is transitive
        by \cref{transitive}.
    Follows by assumption.
\end{proof}
