!D[      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                  ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~                                                                                        !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~Safe%,-.1478;<=>?HUVh! connectionsAn  6https://en.wikipedia.org/wiki/Modular_lattice#Examples/N5/ lattice.$A non-modular lattice formed by the  7https://en.wikipedia.org/wiki/Extended_real_number_lineaffine extended reals along with a NaN7 value that is incomparable to any finite number, i.e.: =pcompare (N5 NaN) (N5 x) = pcompare (N5 x) (N5 NaN) = Nothingfor any finite x. JN5 NaN == N5 NaN = True N5 NaN < N5 (1/0) = True N5 NaN > N5 (-1/0) = True' connectionsA  &https://en.wikipedia.org/wiki/Preorderpreorder on a.A preorder relation (' must satisfy the following two axioms: \forall x: x \leq x  (reflexivity)H \forall a, b, c: ((a \leq b) \wedge (b \leq c)) \Rightarrow (a \leq c)  (transitivity)Given a preorder on a( one may define an equivalence relation + such that a ~~ b if and only if a <~ b and b <~ a.If no partion induced by ++ contains more than a single element, then a* is a partial order and we may define an ) instance such that the following holds: x  y = x + y x <= y = x < y  x + y $Minimal complete definition: either 2 or (. Using 2* can be more efficient for complex types.( connections(A non-strict preorder order relation on a.Is x less than or equal to y?(. is reflexive, anti-symmetric, and transitive. Dx <~ y = x < y || x ~~ y x <~ y = maybe False (<~ EQ) (pcompare x y)for all x, y in a.) connections+A converse non-strict preorder relation on a.Is x greater than or equal to y?). is reflexive, anti-symmetric, and transitive. Dx >~ y = x > y || x ~~ y x >~ y = maybe False (>~ EQ) (pcompare x y)for all x, y in a.* connectionsAn equivalence relation on a.Are x and y comparable?*) is reflexive, symmetric, and transitive.If a implements Ord then we should have  x ?~ y = True.+ connectionsAn equivalence relation on a.Are x and y equivalent?+) is reflexive, symmetric, and transitive. Ex ~~ y = x <~ y && y <~ x x ~~ y = maybe False (~~ EQ) (pcompare x y)$Use this as a lawful substitute for / when comparing floats, doubles, or rationals., connections Negation of +.Are x and y not equivalent?- connectionsA strict preorder relation on a.Is x less than y?-, is irreflexive, asymmetric, and transitive. Px `plt` y = x <~ y && not (y <~ x) x `plt` y = maybe False (< EQ) (pcompare x y)When ( is antisymmetric then a! is a partial order and we have: x `plt` y = x <~ y && x /~ yfor all x, y in a.. connections'A converse strict preorder relation on a.Is x greater than y?., is irreflexive, asymmetric, and transitive. Px `pgt` y = x >~ y && not (y >~ x) x `pgt` y = maybe False (> EQ) (pcompare x y)When ( is antisymmetric then a! is a partial order and we have: x `pgt` y = x >~ y && x /~ yfor all x, y in a./ connectionsA similarity relation on a.Are x and y# either equivalent or incomparable?/< is reflexive and symmetric, but not necessarily transitive. Note this is only equivalent to  in a total order: similar (0/0 :: Float) 5 = TrueIf a implements Ord then we should have (+) = / = ().0 connectionsA partial version of .7Returns the left-hand argument in the case of equality.1 connectionsA partial version of .7Returns the left-hand argument in the case of equality.2 connectionsA partial version of . <x < y = maybe False (< EQ) $ pcompare x y x > y = maybe False (> EQ) $ pcompare x y x <~ y = maybe False (<~ EQ) $ pcompare x y x >~ y = maybe False (>~ EQ) $ pcompare x y x ~~ y = maybe False (~~ EQ) $ pcompare x y x ?~ y = maybe False (const True) $ pcompare x y similar x y = maybe True (~~ EQ) $ pcompare x yIf a implements Ord then we should have 2 x y =   compare x y.3 connectionsA  )https://en.wikipedia.org/wiki/Total_order total order on a.*Note: ideally this would be a subclass of Order, without instances for Float, Double, Rational, etc.`We instead use a constraint kind in order to retain compatibility with the downstream users of Ord.4 connectionsAn  Ahttps://en.wikipedia.org/wiki/Order_theory#Partially_ordered_setsorder on a.*Note: ideally this would be a subclass of Preorder.`We instead use a constraint kind in order to retain compatibility with the downstream users of Eq.5 connectionsA partial version of . 'pcomparing p x y = pcompare (p x) (p y)The partial application  pcomparing f3 induces a lawful preorder for any total function f.!"#$%&'+(2)*,-.01/34543'+(2)*,-.01/5$%&!"# (4)4*4+4,4-4.4041424Safe%,.47HSVXgk}-l connectionsA  ,https://ncatlab.org/nlab/show/adjoint+stringchain( of Galois connections of length 2 or 3.?Connections have many nice properties wrt numerical conversion:Gupper ratf32 (1 / 8) -- eighths are exactly representable in a float1 % 8+upper ratf32 (1 / 7) -- sevenths are not9586981 % 67108864'floor ratf32 &&& ceiling ratf32 $ 1 % 8 (0.125,0.125)'floor ratf32 &&& ceiling ratf32 $ 1 % 7(0.14285713,0.14285715)+Another example avoiding loss-of-precision:f x y = (x + y) - xmaxOdd32 = 1.6777215e7f maxOdd32 2.0 :: Float1.0round2 f64f32 f maxOdd32 2.02.0m connections&A data kind distinguishing links in a  ,https://ncatlab.org/nlab/show/adjoint+stringchain( of Galois connections of length 2 or 3.L#-tagged types are increasing (e.g. , )R#-tagged types are decreasing (e.g. , )BIf a connection is existentialized over this value (i.e. has type forall k. Cast k a b0) then it can provide either of two functions f, h :: a -> b.FThis is useful because it enables rounding, truncation, medians, etc. p connectionsAn  ,https://ncatlab.org/nlab/show/adjoint+tripleadjoint triple of Galois connections.8An adjoint triple is a chain of connections of length 3:f \dashv g \dashv h When applied to a r or q, the two functions of type a -> b returned will be identical.Caution:  Cast f g h must obey f \dashv g \dashv h . This condition is not checked.For detailed properties see .q connections3A Galois connection between two monotone functions.q is the mirror image of r.If you only require one connection there is no particular reason to use one version over the other. However many use cases (e.g. rounding) require an adjoint triple of connections that can lower into a standard connection in either of two ways.Caution:  CastR f g must obey  f \dashv g  . This condition is not checked.For further information see .r connectionsA  /https://ncatlab.org/nlab/show/Galois+connectionGalois connection between two monotone functions.A Galois connection between f and g , written  f \dashv g 0 is an adjunction in the category of preorders.AEach side of the connection may be defined in terms of the other:+ g(x) = \sup \{y \in E \mid f(y) \leq x \} + f(x) = \inf \{y \in E \mid g(y) \geq x \} Caution:  CastL f g must obey  f \dashv g  . This condition is not checked.For further information see .s connectionsLift a l into a functor.Cautionh: This function will result in an invalid connection if the functor alters the internal preorder (e.g. ).t connections.Lift two connections into a connection on the Hhttps://en.wikibooks.org/wiki/Category_Theory/Categories_of_ordered_setscoproduct order (choice id) (ab >>> cd) = (choice id) ab >>> (choice id) cd (flip choice id) (ab >>> cd) = (flip choice id) ab >>> (flip choice id) cdu connections.Lift two connections into a connection on the Hhttps://en.wikibooks.org/wiki/Category_Theory/Categories_of_ordered_setscoproduct orderv connections.Lift two connections into a connection on the Yhttps://en.wikibooks.org/wiki/Order_Theory/Preordered_classes_and_poclasses#product_order product order (strong id) (ab >>> cd) = (strong id) ab >>> (strong id) cd (flip strong id) (ab >>> cd) = (flip strong id) ab >>> (flip strong id) cdw connections.Lift two connections into a connection on the Yhttps://en.wikibooks.org/wiki/Order_Theory/Preordered_classes_and_poclasses#product_order product orderx connections/The defining connections of a bounded preorder.y connections*The defining connections of a total order.1floor ordered &&& ceiling ordered $ (True, False) (False,True)z connectionsThe identity connection.{ connections'Witness to the mirror symmetry between r and q. %swapL . swapR = id swapR . swapL = id| connectionsExtract the upper half of a r.Gupper ratf32 (1 / 8) -- eighths are exactly representable in a float1 % 8+upper ratf32 (1 / 7) -- sevenths are not9586981 % 67108864} connections Map over a r from the right.(This is the unit of the resulting monad: x <~ upper1 c id x compare pi $ upper1 f64f32 id piLT~ connections Zip over a r from the right. connectionsExtract the lower half of a r. Eceiling identity = id ceiling c (x \/ y) = ceiling c x \/ ceiling c y<The latter law is the adjoint functor theorem for preorders.ceiling ratf32 (0 :% 0)NaNceiling ratf32 (13 :% 10) 1.3000001ceiling f64f32 pi 3.1415927 connections Map over a r from the left. ceiling1 identity = id,This is the counit of the resulting comonad: x >~ ceiling1 c id x connections Zip over a r from the left. connectionsGeneralized maximum. connections'Witness to the mirror symmetry between r and q. %swapL . swapR = id swapR . swapL = id connectionsExtract the lower half of a q. connections Map over a q from the left.,This is the counit of the resulting comonad: x >~ lower1 c id x compare pi $ lower1 f64f32 id piGT connections Zip over a q from the left. connectionsExtract the upper half of a q =floor identity = id floor c (x /\ y) = floor c x /\ floor c y<The latter law is the adjoint functor theorem for preorders.floor ratf32 (0 :% 0)NaNfloor ratf32 (13 :% 10)1.3floor f64f32 pi 3.1415925 connections Map over a q from the right. floor1 identity = id(This is the unit of the resulting monad: x <~ floor1 c id x connections Zip over a q from the right. connectionsGeneralized minimum. connectionsBDetermine which half of the interval between 2 representations of a a particular value lies.   c x = 2 (x -  c  x) (} c  x - x):maybe False (== EQ) $ interval f64f32 (midpoint f64f32 pi)True connections1Return the midpoint of the interval containing x.iFor example, the (double-precision) error of the single-precision floating point approximation of pi is:pi - midpoint f64f32 pi3.1786509424591713e-8 connectionsReturn the nearest value to x. round identity = idIf x lies halfway between two finite values, then return the value with the smaller absolute value (i.e. round towards from zero).See  &https://en.wikipedia.org/wiki/Rounding. connections-Lift a unary function over an adjoint triple. round1 identity = id?Results are rounded to the nearest value with ties away from 0. connections.Lift a binary function over an adjoint triple. round2 identity = id?Results are rounded to the nearest value with ties away from 0.*For example, to avoid a loss of precision:f x y = (x + y) - xmaxOdd32 = 1.6777215e7f maxOdd32 2.0 :: Float1.0round2 ratf32 f maxOdd32 2.02.0 connectionsTruncate towards zero. truncate identity = id connections-Lift a unary function over an adjoint triple. truncate1 identity = id#Results are truncated towards zero. connections.Lift a binary function over an adjoint triple. truncate2 identity = id#Results are truncated towards zero. connections Birkoff's  ,https://en.wikipedia.org/wiki/Median_algebramedian operator. ~median x x y = x median x y z = median z x y median x y z = median x z y median (median x w y) w z = median x w (median y w z)median f32f32 1.0 9.0 7.07.0!median f32f32 1.0 9.0 (0.0 / 0.0)9.0 connections Invert a l. upL . downL = downL . upL = id connections Invert a l. upR . downR = downR . upR = id connections Invert a l.2let counit = upper1 (downL $ bounded @Ordering) idcounit (Down LT)Down LTcounit (Down GT)Down LT connections Invert a l.0let unit = lower1 (downR $ bounded @Ordering) idunit (Down LT)Down GTunit (Down GT)Down GT connectionsObtain the principal filter in B generated by an element of A. A subset B of a lattice is an filter if and only if it is an upper set that is closed under finite meets, i.e., it is nonempty and for all x, y in B, the element  meet c x y is also in b.filterL and filterR commute with Down: -filterL c a b <=> filterR c (Down a) (Down b) -filterL c (Down a) (Down b) <=> filterR c a b filterL c a is upward-closed for all a: ba <= b1 && b1 <= b2 => a <= b2 a1 <= b && a2 <= b => minimize c (ceiling c a1) (ceiling c a2) <= bSee 2https://en.wikipedia.org/wiki/Filter_(mathematics) connectionsObtain the principal ideal in B generated by an element of A. A subset B of a lattice is an ideal if and only if it is a lower set that is closed under finite joins, i.e., it is nonempty and for all x, y in B, the element  join c x y is also in B. filterR c a is downward-closed for all a: a >= b1 && b1 >= b2 => a >= b2 ?a1 >= b && a2 >= b => maximize c (floor c a1) (floor c a2) >= bSee 2https://en.wikipedia.org/wiki/Ideal_(order_theory) connections Eliminate an .6lmonpqrstuvwxyz{|}~6monlstuvwxyzr{|}~qpu3w4Safe. connectionsCaution: This assumes that  on your system is 64 bits. connectionsCaution: This assumes that  on your system is 64 bits.''Safe,.Xk connectionsCaution: This assumes that  on your system is 64 bits. connectionsCaution: This assumes that  on your system is 64 bits.Safe,| connectionsA strict preorder relation on a.Is x less than y?, is irreflexive, asymmetric, and transitive. Hx < y = x <~ y && not (y <~ x) x < y = maybe False (< EQ) (pcompare x y)When ( is antisymmetric then a! is a partial order and we have: x < y = x <~ y && x /~ yfor all x, y in a. connections'A converse strict preorder relation on a.Is x greater than y?, is irreflexive, asymmetric, and transitive. Hx > y = x >~ y && not (y >~ x) x > y = maybe False (> EQ) (pcompare x y)When ( is antisymmetric then a! is a partial order and we have: x > y = x >~ y && x /~ yfor all x, y in a. connectionsA wrapper around == that forces  NaN == NaN. connectionsFind the minimum of two values. )min x y == if x <= y then x else y = TrueNote: this function will throw a ArithExceptionM on floats and rationals if one of the arguments is finite and the other is NaN. connectionsFind the minimum of two values. )max x y == if x >= y then x else y = TrueNote: this function will throw a ArithExceptionM on floats and rationals if one of the arguments is finite and the other is NaN. connections$Compare two values in a total order. Nx < y = compare x y == LT x > y = compare x y == GT x == y = compare x y == EQcompare (1/0 :: Double) 0GTcompare (-1/0 :: Double) 0LTcompare (1/0 :: Double) (0/0)GTcompare (-1/0 :: Double) (0/0)LTNote: this function will throw a ArithExceptionM on floats and rationals if one of the arguments is finite and the other is NaN:compare (0/0 :: Double) 0*** Exception: divide by zero connections#Compare on the range of a function. %comparing p x y = compare (p x) (p y)3443 4444444444 Safe4 connectionsAn interval in a poset P.An interval in a poset P is a subset I of P with the following property:B \forall x, y \in I, z \in P: x \leq z \leq y \Rightarrow z \in I  connectionsMap over an interval.Notej this is not a functor, as a non-monotonic map may cause the interval to collapse to the iempty interval. connections,Construct an interval from a pair of points.Note$: Endpoints are preorder-sorted. If pcompare x y = Nothing, then the resulting interval will be empty. connectionsThe iempty interval.iemptyEmpty connections0Construct an interval containing a single point. singleton 11 ... 1 connections$Obtain the endpoints of an interval. connectionsA /https://en.wikipedia.org/wiki/Containment_ordercontainment order3 Safe ,.8=>?@AHXk' connectionsBoolean algebras. -https://ncatlab.org/nlab/show/Boolean+algebraBoolean algebrasw are symmetric Algebra algebras that satisfy both the law of excluded middle and the law of law of non-contradiction: $x \/ neg x = top x /\ non x = bottomIf a is Boolean we also have: non = not = neg connections1A witness to the lawfulness of a boolean algebra. connectionsSymmetric Heyting algebras!A symmetric Heyting algebra is a  7https://ncatlab.org/nlab/show/De+Morgan+Heyting+algebra De MorganD bi-Algebra algebra with an idempotent, antitone negation operator.Laws: x <= y => not y <= not x -- antitone not . not = id -- idempotence x \\ y = not (not y // not x) x // y = not (not y \\ not x)and: converseR x <= converseL xwith equality occurring iff a is a  algebra. connectionsSymmetric negation. not . not = id neg . neg = converseR . converseL non . non = converseL . converseR neg . non = converseR . converseR non . neg = converseL . converseL neg = converseR . not = not . converseL non = not . converseR = converseL . not x \\ y = not (not y // not x) x // y = not (not y \\ not x) connections Exclusive or. &xor x y = (x \/ y) /\ (not x \/ not y) connectionsHeyting and co-Heyting algebras[A Heyting algebra is a bound, distributive lattice equipped with an implication operation.VThe complete of closed subsets of a topological space is the primordial example of a  Coheyting (co-Algebra) algebra.bThe dual complete of open subsets of a topological space is likewise the primordial example of a Heyting algebra. Coheyting:Co-implication to a* is the lower adjoint of disjunction with a: x \\ a <= y <=> x <= y \/ aHNote that co-Heyting algebras needn't obey the law of non-contradiction: 3EQ /\ non EQ = EQ /\ GT \\ EQ = EQ /\ GT = EQ /= LTSee 0https://ncatlab.org/nlab/show/co-Heyting+algebraHeyting:Implication from a* is the upper adjoint of conjunction with a: x <= a // y <=> a /\ x <= yHSimilarly, Heyting algebras needn't obey the law of the excluded middle: 3EQ \/ neg EQ = EQ \/ EQ // LT = EQ \/ LT = EQ /= GTSee -https://ncatlab.org/nlab/show/Heyting+algebra connections2The defining connection of a (co-)Heyting algebra. Galgebra @'L x = CastL (\\ x) (\/ x) algebra @'R x = CastR (x /\) (x //) connectionsA  0https://ncatlab.org/nlab/show/co-Heyting+algebrabi-Heyting algebra.Laws: neg x <= non xwith equality occurring iff a is a  algebra. connectionsA convenience alias for a  0https://ncatlab.org/nlab/show/co-Heyting+algebraco-Heyting algebra. connections*A convenience alias for a Heyting algebra. connectionsBounded  %https://ncatlab.org/nlab/show/latticelattices.A lattice is a partially ordered set in which every two elements have a unique join (least upper bound or supremum) and a unique meet (greatest lower bound or infimum).%A bound lattice adds unique elements  and   , which serve as identities to   and , respectively. Neutrality: x     = x x   = x    x  = x     x  = x  Associativity x   (y   z) = (x   y)   z x  (y  z) = (x  y)  z  Commutativity x   y = y   x x  y = y  x  Idempotency x   x = x x  x = x  Absorption (x   y)  y = y (x  y)   y = y See  ,https://en.wikipedia.org/wiki/Absorption_law Absorption.NNote that distributivity is _not_ a requirement for a complete. However when a is distributive we have:  x y z =   x y z See  -https://en.wikipedia.org/wiki/Lattice_(order). connections/The defining connection of a bound semilattice.  and / are defined by the left and right adjoints to a -> (). connections)The defining connection of a semilattice.  and / are defined by the left and right adjoints to  a -> (a, a). connections*A convenience alias for a meet semilattice connections*A convenience alias for a join semilattice connections Lattice meet.  (/\) = curry $ floor semilattice connectionsGreatest lower bound operator. cglb x x y = x glb x y z = glb z x y glb x y z = glb x z y glb (glb x w y) w z = glb x w (glb y w z)glb 1.0 9.0 7.07.0glb 1.0 9.0 (0.0 / 0.0)9.0Cglb (fromList [1..3]) (fromList [3..5]) (fromList [5..7]) :: IntSetfromList [3,5] connections)The unique top element of a bound lattice x /\ top = x x \/ top = top  connections Lattice join.  (\/) = curry $ lower semilattice  connectionsLeast upper bound operator.The order dual of .lub 1.0 9.0 7.07.0lub 1.0 9.0 (0.0 / 0.0)1.0  connections,The unique bottom element of a bound lattice $x /\ bottom = bottom x \/ bottom = x  connectionsLogical implication:6 a \Rightarrow b = \vee \{x \mid x \wedge a \leq b \} Laws: x /\ y <= z <=> x <= y // z x // y <= x // (y \/ z) x <= y => z // x <= z // y y <= x // (x /\ y) x <= y <=> x // y = top (x \/ z) // y <= x // y (x /\ y) // z = x // y // z x // (y /\ z) = x // y /\ x // z x /\ x // y = x /\ yFalse // FalseTrue False // TrueTrue True // FalseFalse True // TrueTrue  connectionsIntuitionistic equivalence.When a is Bool this is 'if-and-only-if'. connectionsLogical negation.   x = x    Laws: neg bottom = top neg top = bottom x <= neg (neg x) neg (x \/ y) <= neg x neg (x // y) = neg (neg x) /\ neg y neg (x \/ y) = neg x /\ neg y x /\ neg x = bottom neg (neg (neg x)) = neg x neg (neg (x \/ neg x)) = top!Some logics may in addition obey  7https://ncatlab.org/nlab/show/De+Morgan+Heyting+algebraDe Morgan conditions. connections The Algebra ( -https://ncatlab.org/nlab/show/excluded+middlenot necessarily excluded) middle operator. connections*Default constructor for a Algebra algebra. connectionsDAn adjunction between a Algebra algebra and its Boolean sub-algebra.+Double negation is a meet-preserving monad. connectionsLogical co-implication:6 a \Rightarrow b = \wedge \{x \mid a \leq b \vee x \} Laws: x \\ y <= z <=> x <= y \/ z x \\ y >= (x /\ z) \\ y x >= y => x \\ z >= y \\ z x >= x \\ y x >= y <=> y \\ x = bottom x \\ (y /\ z) >= x \\ y z \\ (x \/ y) = z \\ x \\ y (y \/ z) \\ x = y \\ x \/ z \\ x x \/ y \\ x = x \/ yFalse \\ FalseFalse False \\ TrueFalse True \\ FalseTrue True \\ TrueFalseFor many collections (e.g. )  coincides with the native  operator.:set -XOverloadedLists[GT,EQ] Set.\\ [LT]fromList [EQ,GT][GT,EQ] \\ [LT]fromList [EQ,GT] connectionsIntuitionistic co-equivalence. connectionsLogical  1https://ncatlab.org/nlab/show/co-Heyting+negation co-negation.   x =   xLaws: non bottom = top non top = bottom x >= non (non x) non (x /\ y) >= non x non (y \\ x) = non (non x) \/ non y non (x /\ y) = non x \/ non y x \/ non x = top non (non (non x)) = non x non (non (x /\ non x)) = bottom connectionsThe co-Heyting  1https://ncatlab.org/nlab/show/co-Heyting+boundaryboundary operator. x = boundary x \/ (non . non) x boundary (x /\ y) = (boundary x /\ y) \/ (x /\ boundary y) -- (Leibniz rule) boundary (x \/ y) \/ boundary (x /\ y) = boundary x \/ boundary y connections-Default constructor for a co-Heyting algebra. connectionsGAn adjunction between a co-Heyting algebra and its Boolean sub-algebra.-Double negation is a join-preserving comonad. connectionsLeft converse operator. connectionsRight converse operator. connections*Default constructor for a Heyting algebra. connections-Default constructor for a co-Heyting algebra.0 connectionsZAll minimal elements of the upper lattice cover all maximal elements of the lower lattice.U connections(Subdirectly irreducible Algebra algebra.&     &     46 5 88 Safe.ޤa connectionsSee  8https://en.wikipedia.org/wiki/Binary_relation#Properties.CNote that these properties do not exhaust all of the possibilities.5As an example over the natural numbers, the relation a \# b  defined by  a > 2 > is neither symmetric nor antisymmetric, let alone asymmetric.e connectionsCheck a ' is internally consistent.This is a required property.f connectionsCheck that an 4 is internally consistent.This is a required property.g connections> \forall a, b: (a \leq b) \wedge (b \leq a) \Rightarrow a = b ( is an antisymmetric relation.This is a required property.h connections \forall a: (a \leq a) ( is a reflexive relation.This is a required property.i connectionsH \forall a, b, c: ((a \leq b) \wedge (b \leq c)) \Rightarrow (a \leq c) ( is an transitive relation.This is a required property.j connections, \forall a, b: ((a \leq b) \vee (b \leq a)) ( is a connex relation.k connections4 \forall a, b: (a \lt b) \Rightarrow \neg (b \lt a) lt is an asymmetric relation.This is a required property.l connections \forall a: \neg (a \lt a) lt is an irreflexive relation.This is a required property.m connectionsE \forall a, b, c: ((a \lt b) \wedge (b \lt c)) \Rightarrow (a \lt c) lt is a transitive relation.This is a required property.n connectionsC \forall a, b: \neg (a = b) \Rightarrow ((a \lt b) \vee (b \lt a)) lt is a semiconnex relation.o connectionsr \forall a, b, c: ((a \lt b) \vee (a = b) \vee (b \lt a)) \wedge \neg ((a \lt b) \wedge (a = b) \wedge (b \lt a)) In other words, exactly one of a \lt b, a = b, or b \lt a holds.If lt< is a trichotomous relation then the set is totally ordered.p connectionsP \forall x, y, z, w: x \lt y \wedge y \sim z \wedge z \lt w \Rightarrow x \lt w A  'https://en.wikipedia.org/wiki/Semiorder semiorder does not allow 2-2 chains.r connections/ \forall a, b: (a = b) \Leftrightarrow (b = a) + is a symmetric relation.This is a required property.s connections \forall a: (a = a) + is a reflexive relation.This is a required propertyt connections? \forall a, b, c: ((a = b) \wedge (b = c)) \Rightarrow (a = c) + is a transitive relation.This is a required property.u connections \forall a: (a \# a) 4For example, "e is a reflexive relation but > is not.v connections \forall a: \neg (a \# a) 8For example, > is an irreflexive relation, but "e is not.w connectionsC \forall a, b: ((a \# b) \wedge (b \# a)) \Rightarrow (a \equiv b) For example, the relation over the integers in which each odd number is related to itself is a coreflexive relation. The equality relation is the only example of a relation that is both reflexive and coreflexive, and any coreflexive relation is a subset of the equality relation.x connections? \forall a, b: (a \# b) \Rightarrow ((a \# a) \wedge (b \# b)) y connectionsB \forall a, b, c: ((a \# b) \wedge (a \# c)) \Rightarrow (b \# c)  For example, =* is a right Euclidean relation because if x = y and x = z then y = z.z connectionsB \forall a, b, c: ((b \# a) \wedge (c \# a)) \Rightarrow (b \# c)  For example, =) is a left Euclidean relation because if x = y and x = z then y = z.{ connectionsB \forall a, b, c: ((a \# b) \wedge (b \# c)) \Rightarrow (a \# c) TFor example, "is ancestor of" is a transitive relation, while "is parent of" is not.| connections( \forall a, b: ((a \# b) \vee (b \# a)) CFor example, "e is a connex relation, while 'divides evenly' is not.IA connex relation cannot be symmetric, except for the universal relation.} connectionsF \forall a, b: \neg (a \equiv b) \Rightarrow ((a \# b) \vee (b \# a)) [A binary relation is semiconnex if it relates all pairs of _distinct_ elements in some way.CA relation is connex if and only if it is semiconnex and reflexive.~ connectionsx \forall a, b, c: ((a \# b) \vee (a \doteq b) \vee (b \# a)) \wedge \neg ((a \# b) \wedge (a \doteq b) \wedge (b \# a)) In other words, exactly one of a \# b,  a \doteq b, or b \# a holds.:For example, > is a trichotomous relation, while "e is not. Note that  trichotomous (>)  should hold for any  instance. connections1 \forall a, b: (a \# b) \Leftrightarrow (b \# a) For example, "is a blood relative of" is a symmetric relation, because A is a blood relative of B if and only if B is a blood relative of A. connections2 \forall a, b: (a \# b) \Rightarrow \neg (b \# a) 7For example, > is an asymmetric relation, but "e is not.QA relation is asymmetric if and only if it is both antisymmetric and irreflexive. connections? \forall a, b: (a \# b) \wedge (b \# a) \Rightarrow a \equiv b wFor example, "e is an antisymmetric relation; so is >, but vacuously (the condition in the definition is always false)."abcdefghijklmnopqrstuvwxyz{|}~"abcdefghijkmlnopqrstuvwx{zy|}~b1c0 Safe ,.HSVXk  connectionsQ \forall x, y : f \dashv g \Rightarrow f (x) \leq y \Leftrightarrow x \leq g (y) OA Galois connection is an adjunction of preorders. This is a required property. connections2 \forall a: f a \leq b \Leftrightarrow a \leq g b +A monotone Galois connection is defined by adjunction (<~) (<~)5, while an antitone Galois connection is defined by adjunction (>~) (<~). connections9 \forall x : f \dashv g \Rightarrow x \leq g \circ f (x) This is a required property. connections9 \forall x : f \dashv g \Rightarrow x \leq g \circ f (x) This is a required property. connections \forall a: f (g a) \sim a  connections6 \forall x, y : x \leq y \Rightarrow f (x) \leq f (y) This is a required property. connections3 \forall a, b: a \leq b \Rightarrow f(a) \leq f(b)  connectionsd \forall x: f \dashv g \Rightarrow counit \circ f (x) \sim f (x) \wedge unit \circ g (x) \sim g (x) See 3https://ncatlab.org/nlab/show/idempotent+adjunction connections% \forall a: g \circ f (a) \sim f (a)  Safe=>?Xk;;Safe%,Xk connectionsA total version of . connectionsTShift by n 'units of least precision' where the ULP is determined by the denominatorThis is an analog of  for rationals.Safe%.X_kt connectionsKCompute the signed distance between two floats in units of least precision.ulp32 1.0 (shift32 1 1.0) Just (LT,1)ulp32 (0.0/0.0) 1.0Nothing connections,Compare two floats for approximate equality.;Required accuracy is specified in units of least precision.See  [https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/. connectionsShift a float by n units of least precision. shift32 1 01.0e-45shift32 1 1 - 1 1.1920929e-7shift32 1 $ 0/0Infinityshift32 (-1) $ 0/0 -Infinityshift32 1 $ 1/0Infinity connectionsLCompute the signed distance between two doubles in units of least precision.ulp64 1.0 (shift64 1 1.0) Just (LT,1)ulp64 (0.0/0.0) 1.0Nothing connections=Compare two double-precision floats for approximate equality.;Required accuracy is specified in units of least precision. See also  [https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/. connections Shift by n units of least precision. shift64 1 05.0e-324shift64 1 1 - 12.220446049250313e-16shift64 1 $ 0/0Infinityshift64 (-1) $ 0/0 -Infinityshift64 1 $ 1/0Infinity##Safe%.Xk 1 connectionsSShift by n 'units of least precision' where the ULP is determined by the precision.This is an analog of  for fixed point numbers.&      &       Safe%,.Xk8 connectionsThe  is valued in seconds connectionsThe  is valued in seconds.)Data.Connection.Cast.ceiling f32sys (0/0)PosInf&Data.Connection.Cast.ceiling f32sys piHFinite (MkSystemTime {systemSeconds = 3, systemNanoseconds = 141592742}) connectionsThe  is valued in seconds.)Data.Connection.Cast.ceiling f64sys (0/0)PosInf&Data.Connection.Cast.ceiling f64sys piHFinite (MkSystemTime {systemSeconds = 3, systemNanoseconds = 141592654}) connectionsThe  is valued in seconds.  connectionsThe 0 is valued in seconds (to nanosecond precision).! connections"Return the difference between two   s in seconds;diffSystemTime (MkSystemTime 0 0) (MkSystemTime 0 maxBound) -4.294967295 divMod (maxBound @Word32) (10^9) (4,294967295)   !  ! Safe .=>?@AHXk" connectionsA  ,https://ncatlab.org/nlab/show/adjoint+stringchain( of Galois connections of length 2 or 3."#$%$%"#Safeg/lmonpqrstuvw{|}~#$%/mon$r%q#pl|}~{stuvw ! "#$%&%'#(#)#*%+,%+-%+.%+/%+0%+1%+2%+3%+4%+5%+6%+7%%%89%8:;<=;<>;<?;<@ABCABDABEABFABGHHIJJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                         ! " # $ % & ' ( ) * + , - . / 0 1  2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~                                                                                                                      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~  %%%####%(connections-0.3.2-8ciho7g6per1gqFe8x6sXIData.Order.Syntax Data.OrderData.Connection.RatioData.Connection.FixedData.Connection.CastData.Connection.TimeData.Connection.WordData.Connection.IntData.Order.Interval Data.LatticeData.Order.PropertyData.Connection.PropertyData.Lattice.PropertyData.Connection.FloatData.Connection.ClassData.OrdmaxmincompareData.Order.Total comparingData.ConnectionPropertyDownData.SetSet\\GHC.Realreduceshift32ghc-prim GHC.ClassesEqOrd GHC.TypesOrderingbaseRatio:%LTEQGT Data.Fixed showFixedMkFixedFixed resolution HasResolutionUniDeciCentiMilliMicroNanoPicoControl.Category>>><<<-extended-reals-0.2.4.0-GiHkOq29oNk7n58CoOmuKpData.ExtendedRealPosInfFiniteNegInfExtended time-1.8.0.2#Data.Time.Clock.Internal.SystemTime getSystemTimesystemNanoseconds systemSeconds MkSystemTime SystemTimeN5getN5BasegetBasePreorder<~>~?~~~/~pltpgtsimilarpmaxpminpcompareTotalOrder pcomparing$fPreorderIntSet$fPreorderIntMap $fPreorderSet $fPreorderMap$fPreorder(,,,,)$fPreorder(,,,)$fPreorder(,,) $fPreorder(,)$fPreorderEither$fPreorderExtended$fPreorderNonEmpty $fPreorder[]$fPreorderMaybe$fPreorderIdentity $fPreorderAll $fPreorderAny $fPreorderMin $fPreorderMax$fPreorderDual$fPreorderDown$fPreorderComplex$fPreorderSystemTime$fPreorderRatio$fPreorderBase $fPreorderN5$fEqBase $fOrdBase $fShowBase $fFunctorBase$fApplicativeBase$fEqN5$fShowN5 $fFunctorN5$fApplicativeN5$fPreorderDouble$fPreorderFloat$fPreorderFixed$fPreorderInteger$fPreorderInt64$fPreorderInt32$fPreorderInt16$fPreorderInt8 $fPreorderInt$fPreorderNatural$fPreorderWord64$fPreorderWord32$fPreorderWord16$fPreorderWord8$fPreorderWord$fPreorderChar$fPreorderOrdering$fPreorderBool $fPreorder()$fPreorderVoidCastSideLRCastRCastLmappedchoiceselectstrongdivideboundedorderedidentityswapLupperupper1upper2ceilingceiling1ceiling2maximizeswapRlowerlower1lower2floorfloor1floor2minimizeintervalmidpointroundround1round2truncate truncate1 truncate2medianupLupRdownLdownRfilterLfilterRextendextended$fCategoryTYPECastbndbini08w08w08w16i08w16i16w16w08w32w16w32i08w32i16w32i32w32w08w64w16w64w32w64wxxw64i08w64i16w64i32w64i64w64ixxw64w08wxxw16wxxw32wxxw64wxxi08wxxi16wxxi32wxxi64wxxixxwxxw08natw16natw32natw64natwxxnati08nati16nati32nati64natixxnatintnatw08i16i08i16w08i32w16i32i08i32i16i32w08i64w16i64w32i64i08i64i16i64i32i64ixxi64w08ixxw16ixxw32ixxi08ixxi16ixxi32ixxi64ixxw08intw16intw32intw64intwxxinti08inti16inti32inti64intixxint<>==/=<=>=Intervalimap...iempty singletonendptscontains$fPreorderInterval $fEqInterval$fShowIntervalBooleanboolean SymmetricnotxorAlgebraalgebra Biheyting CoheytingHeyting Semilatticebound semilatticeMeetJoinLattice/\glbtop\/lubbottom//iffnegmiddleheytingbooleanRequivnonboundary coheytingbooleanL converseL converseR symmetricR symmetricL$fSemilatticekIntSet$fSemilatticeLSet$fSemilatticekInt$fSemilatticekInt64$fSemilatticekInt32$fSemilatticekInt16$fSemilatticekInt8$fSemilatticekWord$fSemilatticekWord64$fSemilatticekWord32$fSemilatticekWord16$fSemilatticekWord8$fSemilatticekOrdering$fSemilatticekBool$fSemilatticek()$fSemilatticeREither$fSemilatticeRExtended$fSemilatticeRMaybe$fSemilatticeLIntMap$fSemilatticeLMap$fSemilatticeLEither$fSemilatticeLExtended$fSemilatticeLMaybe$fSemilatticek(,)$fAlgebraLIntMap $fAlgebraLMap$fAlgebraRIntSet$fAlgebraLIntSet $fAlgebraLSet $fAlgebraRInt $fAlgebraLInt$fAlgebraRInt64$fAlgebraLInt64$fAlgebraRInt32$fAlgebraLInt32$fAlgebraRInt16$fAlgebraLInt16$fAlgebraRInt8$fAlgebraLInt8$fAlgebraRWord$fAlgebraLWord$fAlgebraRWord64$fAlgebraLWord64$fAlgebraRWord32$fAlgebraLWord32$fAlgebraRWord16$fAlgebraLWord16$fAlgebraRWord8$fAlgebraLWord8$fAlgebraROrdering$fAlgebraLOrdering$fAlgebraRBool$fAlgebraLBool $fAlgebraR() $fAlgebraL() $fAlgebraL(,)$fAlgebraREither$fAlgebraREither0$fAlgebraRExtended$fAlgebraRMaybe $fAlgebraR(,)$fSymmetricIntSet$fSymmetric(,)$fSymmetricOrdering$fSymmetricBool $fSymmetric() $fBoolean(,) $fBooleanBool $fBoolean()Rel==><=>xor3preorderorderantisymmetric_le reflexive_le transitive_le connex_le asymmetric_ltirreflexive_lt transitive_lt semiconnex_lttrichotomous_ltchain_22chain_31 symmetric_eq reflexive_eq transitive_eq reflexive irreflexive coreflexivequasireflexive euclideanR euclideanL transitiveconnex semiconnex trichotomous symmetric asymmetric antisymmetricadjointadjointLadjointR adjunctionclosedclosedLclosedRkernelkernelLkernelR invertible monotonic monotonicR monotonicLmonotone idempotent idempotentL idempotentR projectiveheyting0heyting1heyting2heyting3heyting4heyting5heyting6heyting7heyting8heyting9 heyting10 heyting11 heyting12 heyting13 heyting14 heyting15 heyting16 heyting17 coheyting0 coheyting1 coheyting2 coheyting3 coheyting4 coheyting5 coheyting6 coheyting7 coheyting8 coheyting9 coheyting10 coheyting11 coheyting12 coheyting13 coheyting14 coheyting15 coheyting16 coheyting17 coheyting18 coheyting19 coheyting20 symmetric1 symmetric2 symmetric3 symmetric4 symmetric5 symmetric6 symmetric7 symmetric8 symmetric9 symmetric10 symmetric11 symmetric12 symmetric13boolean0boolean1boolean2boolean3boolean4boolean5boolean6shiftrratw08ratw16ratw32ratw64ratwxxratnatrati08rati16rati32rati64ratixxratintratratf32w08f32w16f32w32f32w64f32wxxf32natf32i32f32i64f32ixxf32intf32i08f32i16f32f32f64f32ratf32ulp32near32f64w08f64w16f64w32f64w64f64wxxf64natf64i08f64i16f64i32f64i64f64ixxf64intf64f64ratf64ulp64near64shift64shiftff00intf01f00f02f00f02f01f03f00f03f01f03f02f06f00f06f01f06f02f06f03f09f00f09f01f09f02f09f03f09f06f12f00f12f01f12f02f12f03f12f06f12f09f32fixf64fixratfixsysixxf32sysf64sysratsysf09sysdiffSystemTime ConnectioncastcastLcastR$fConnectionLDoubleExtended$fConnectionLDoubleExtended0$fConnectionLDoubleExtended1$fConnectionLDoubleExtended2$fConnectionLDoubleExtended3$fConnectionkDoubleExtended$fConnectionkDoubleExtended0$fConnectionkDoubleExtended1$fConnectionLDoubleExtended4$fConnectionLDoubleExtended5$fConnectionLDoubleExtended6$fConnectionkDoubleExtended2$fConnectionkDoubleExtended3$fConnectionkDoubleExtended4$fConnectionLFloatExtended$fConnectionLFloatExtended0$fConnectionLFloatExtended1$fConnectionLFloatExtended2$fConnectionLFloatExtended3$fConnectionLFloatExtended4$fConnectionkFloatExtended$fConnectionkFloatExtended0$fConnectionLFloatExtended5$fConnectionLFloatExtended6$fConnectionLFloatExtended7$fConnectionLFloatExtended8$fConnectionkFloatExtended1$fConnectionkFloatExtended2$fConnectionkRatioExtended$fConnectionkRatioExtended0$fConnectionkRatioExtended1$fConnectionkRatioExtended2$fConnectionkRatioExtended3$fConnectionkRatioExtended4$fConnectionkRatioExtended5$fConnectionkRatioExtended6$fConnectionkRatioExtended7$fConnectionkRatioExtended8$fConnectionkRatioExtended9$fConnectionkRatioExtended10$fConnectionkRatioExtended11$fConnectionkRatioExtended12$fConnectionLExtendedMaybe$fConnectionLExtendedMaybe0$fConnectionLExtendedMaybe1$fConnectionLExtendedMaybe2$fConnectionLExtendedMaybe3$fConnectionLExtendedMaybe4$fConnectionLExtendedMaybe5$fConnectionLExtendedMaybe6$fConnectionLExtendedMaybe7$fConnectionLExtendedMaybe8$fConnectionkSystemTimeInt$fConnectionkInt64Int$fConnectionkExtendedInt$fConnectionkExtendedInt0$fConnectionkExtendedInt1$fConnectionkExtendedInt2$fConnectionkExtendedInt3$fConnectionkExtendedInt4$fConnectionkIntInt64$fConnectionkExtendedInt64$fConnectionkExtendedInt640$fConnectionkExtendedInt641$fConnectionkExtendedInt642$fConnectionkExtendedInt643$fConnectionkExtendedInt644$fConnectionkExtendedInt32$fConnectionkExtendedInt320$fConnectionkExtendedInt321$fConnectionkExtendedInt322$fConnectionkExtendedInt16$fConnectionkExtendedInt160$fConnectionkRatioDouble$fConnectionkRatioFloat$fConnectionkDoubleFloat$fConnectionkFixedFixed$fConnectionkFixedFixed0$fConnectionkFixedFixed1$fConnectionkFixedFixed2$fConnectionkFixedFixed3$fConnectionkFixedFixed4$fConnectionkFixedFixed5$fConnectionkFixedFixed6$fConnectionkFixedFixed7$fConnectionkFixedFixed8$fConnectionkFixedFixed9$fConnectionkFixedFixed10$fConnectionkFixedFixed11$fConnectionkFixedFixed12$fConnectionkFixedFixed13$fConnectionkFixedFixed14$fConnectionkFixedFixed15$fConnectionkFixedFixed16$fConnectionkFixedFixed17$fConnectionkFixedFixed18$fConnectionkFixedFixed19$fConnectionkFixedInteger$fConnectionLIntegerNatural$fConnectionLIntNatural$fConnectionLInt64Natural$fConnectionLInt32Natural$fConnectionLInt16Natural$fConnectionLInt8Natural$fConnectionLWordNatural$fConnectionLWord64Natural$fConnectionLWord32Natural$fConnectionLWord16Natural$fConnectionLWord8Natural$fConnectionLIntWord$fConnectionLInt64Word$fConnectionLInt32Word$fConnectionLInt16Word$fConnectionLInt8Word$fConnectionkWord64Word$fConnectionLWord32Word$fConnectionLWord16Word$fConnectionLWord8Word$fConnectionLIntWord64$fConnectionLInt64Word64$fConnectionLInt32Word64$fConnectionLInt16Word64$fConnectionLInt8Word64$fConnectionkWordWord64$fConnectionLWord32Word64$fConnectionLWord16Word64$fConnectionLWord8Word64$fConnectionLInt32Word32$fConnectionLInt16Word32$fConnectionLInt8Word32$fConnectionLWord16Word32$fConnectionLWord8Word32$fConnectionLInt16Word16$fConnectionLInt8Word16$fConnectionLWord8Word16$fConnectionLInt8Word8$fConnectionkIntBool$fConnectionkInt64Bool$fConnectionkInt32Bool$fConnectionkInt16Bool$fConnectionkInt8Bool$fConnectionkWordBool$fConnectionkWord64Bool$fConnectionkWord32Bool$fConnectionkWord16Bool$fConnectionkWord8Bool$fConnectionkOrderingBool$fConnectionkaa|| GHC.MaybeJustGHC.Base$idWordIntFloatDoubleRational