1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Order
open Prop

/// A partial order is a relation that obeys some laws: in
/// \gls{fstar}, such constraints are trivially encoded as
/// \emph{refinements}.

/// Refinements filters the inhabitants of a type: below, the type
/// \fcode{order} is inhabited by binary predicates that are
/// reflexive, transitive and antisymetric.

/// A value \fcode{v} of type \fcode{order int} witness the proof that
/// \fcode{v} is reflective, transitive and antisymetric.

//@regexp=⊑(?!\))|!\twocharwidth{\scalebox{0.8}[0.95]{$\sqsubseteq$}}!
let refl    (():'a->'a->bool): prop = forall   x. xx
//@regexp=⊑(?!\))|!\twocharwidth{\scalebox{0.8}[0.95]{$\sqsubseteq$}}!
let antisym (():'a->'a->bool): prop = forall x y. (xy /\ yx) ==> x==y
//@regexp=⊑(?!\))|!\twocharwidth{\scalebox{0.8}[0.95]{$\sqsubseteq$}}!
let trans (():'a->'a->bool): prop = forall x y z. (xy /\ yz) ==> xz

type order 'a = f:('a->'a->bool)  {refl f /\ trans f /\ antisym f}