Idris2Doc : Data.Int.Order

Data.Int.Order

Implementation of ordering relations for the primitive type `Int`
This is full of tricks as `Int` is a primitive type that can only
be interacted with using either literals or built-in functions.
The exported interface should however be safe.

Definitions

strictRefl : a=b-> Lazy c->c
  Pattern-match on an equality proof so that the second argument to
strictRefl is only returned once the first is canonical.

Totality: total
Visibility: export
dataLT : Int->Int->Type
  `LT a b` is a proof that `a` is less than `b` which is to say that
the function call `a < b` returns `True`.

NB: we do not re-export the constructor so that users cannot force
our magic functions to blow up in absurd contexts by bypassing the
safety measures introduced by the `strictX` functions.
We do provide functions corresponding to the wrapping and unwrapping
of `LT` but, crucially, they do not let people force `LT` proofs to
be in canonical form.

Totality: total
Visibility: export
Constructor: 
MkLT : a<b=True->LTab
mkLT : a<b=True->LTab
  We may prove `LT a b` by using a proof that `a < b` returns `True`.

Totality: total
Visibility: export
runLT : LTab->a<b=True
  From a proof that `LT a b`, we may concluded that `a < b` returns `True`.

Totality: total
Visibility: export
strictLT : LTab-> Lazy c->c
  Do not trust arbitrary `LT` proofs when manufacturing magic ones:
be strict!

Totality: total
Visibility: export
decide : (a : Int) -> (b : Int) ->Dec (LTab)
  LT is decidable, by virtue of being the reflection of a boolean function

Totality: total
Visibility: export
trans : LTab->LTbc->LTa (theIntc)
  LT is a transitive relation. This cannot be proven so we use a magic trick.

Totality: total
Visibility: export
irrefl : Not (LTaa)
  LT is an irreflexive relation.
The crash will never happen because the `LT a a` argument will never reduce
to a canonical form (unless the built-in function (<) is buggy).

Totality: total
Visibility: export
GT : Int->Int->Type
  GT is defined in terms of LT to avoid code duplication

Totality: total
Visibility: public export
LT_not_GT : LTab->Not (GTab)
Totality: total
Visibility: export
GT_not_LT : GTab->Not (LTab)
Totality: total
Visibility: export
dataEQ : Int->Int->Type
  `EQ a b` is a proof that `a` is equal to `b` which is to say that
the function call `a == b` returns `True`.

NB: we do not re-export the constructor so that users cannot force
our magic functions to blow up in absurd contexts by bypassing the
safety measures introduced by the `strictX` functions.
We do provide functions corresponding to the wrapping and unwrapping
of `EQ` but, crucially, they do not let people force `EQ` proofs to
be in canonical form.

Totality: total
Visibility: export
Constructor: 
MkEQ : a==b=True->EQab
mkEQ : a==b=True->EQab
  We may prove `EQ a b` by using a proof that `a == b` returns `True`.

Totality: total
Visibility: export
runEQ : EQab->a==b=True
  From a proof that `EQ a b`, we may concluded that `a == b` returns `True`.

Totality: total
Visibility: export
strictEQ : EQab-> Lazy c->c
  Do not trust arbitrary `EQ` proofs when manufacturing magic ones:
be strict!

Totality: total
Visibility: export
decide : (a : Int) -> (b : Int) ->Dec (EQab)
  EQ is decidable, by virtue of being the reflection of a boolean function

Totality: total
Visibility: export
refl : EQaa
  EQ is a reflexive relation

Totality: total
Visibility: export
elimEQ : (0p : (Int->Type)) ->EQab->pa->pb
  EQ is substitutive

Totality: total
Visibility: export
reflect : EQab->a=b
  EQ implies propositional equality

Totality: total
Visibility: export
sym : EQab->EQba
  EQ is a symmetric relation

Totality: total
Visibility: export
trans : EQab->EQbc->EQac
  EQ is a transitive relation

Totality: total
Visibility: export
trans_LT_EQ : LTab->EQbc->LTac
Totality: total
Visibility: export
trans_EQ_LT : EQab->LTbc->LTac
Totality: total
Visibility: export
LT_not_EQ : LTab->Not (EQab)
Totality: total
Visibility: export
EQ_not_LT : EQab->Not (LTab)
Totality: total
Visibility: export
EQ_not_GT : EQab->Not (GTab)
Totality: total
Visibility: export
GT_not_EQ : GTab->Not (EQab)
Totality: total
Visibility: export
dataLTE : Int->Int->Type
  `LTE a b` is a proof that `a` is less or equal to `b` which is to say that
the function call `a < b` or `a == b` returns `True`.

NB: we do not re-export the constructor so that users cannot force
our magic functions to blow up in absurd contexts by bypassing the
safety measures introduced by the `strictX` functions.

Totality: total
Visibility: export
Constructors:
MkLT : a<b=True->LTEab
MkEQ : a==b=True->LTEab
runLTE : LTEab->Either (LTab) (EQab)
  Unwrap an LTE proof to get either an LT or an EQ one

Totality: total
Visibility: export
strictLTE : LTEab-> Lazy c->c
  Do not trust arbitrary `LTE` proofs when manufacturing magic ones:
be strict!

Totality: total
Visibility: export
decide : (a : Int) -> (b : Int) ->Dec (LTEab)
  LTE is decidable by virture of both LT and EQ being decidable

Totality: total
Visibility: export
refl : LTEaa
  LTE is a reflexive relation

Totality: total
Visibility: export
trans_LT_LTE : LTab->LTEbc->LTac
Totality: total
Visibility: export
trans_LTE_LT : LTEab->LTbc->LTac
Totality: total
Visibility: export
inject_LT_LTE : LTab->LTEab
Totality: total
Visibility: export
inject_EQ_LTE : EQab->LTEab
Totality: total
Visibility: export
trans : LTEab->LTEbc->LTEac
  LTE is a transitive relation

Totality: total
Visibility: export
antisym : LTEab->LTEba->EQab
  LTE is an antisymmetric relation

Totality: total
Visibility: export
GTE : Int->Int->Type
  GTE is defined in terms of LTE to avoid code duplication

Totality: total
Visibility: public export
trichotomous : (a : Int) -> (b : Int) ->TrichotomousLTEQGTab
  Any pair of Ints is related either via LT, EQ, or GT

Totality: total
Visibility: export
decide_LT_GTE : (a : Int) -> (b : Int) ->Either (LTab) (GTEab)
  Any pair of Ints is related either via LT or GTE

Totality: total
Visibility: export
decide_LTE_GT : (a : Int) -> (b : Int) ->Either (LTEab) (GTab)
  Any pair of Ints is related either via LTE or GT

Totality: total
Visibility: export
suc_LT_LTE : LTab->LTE (a+1) b
  Adding one to a strictly smaller Int, yields a smaller Int

Totality: total
Visibility: export
pred_LT_LTE : LTab->LTEa (b-1)
  Subtracting one to a strictly larger Int, yields a larger Int

Totality: total
Visibility: export
sucBounded : LTab->LTa (a+1)
  Adding one to an Int yields a strictly larger one,
provided there is no overflow

Totality: total
Visibility: export