h$      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                                                                                                                                                                                                                                                                                                                                                                               Safe-./2589<=>?  connections4Positive rationals, extended with an absorbing zero.  is the canonical  0https://en.wikipedia.org/wiki/Semifield#Examples semifield. connectionsA  &https://en.wikipedia.org/wiki/Preorderpreorder on a.A preorder relation ' must satisfy the following two axioms: \forall x: x \leq x  (reflexivity) \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  or . Using * 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. x <~ 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. x >~ 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. x ~~ 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. x `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. x `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 () =  = (). connectionsA partial version of .7Returns the left-hand argument in the case of equality. connectionsA partial version of .7Returns the left-hand argument in the case of equality. 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  x y =   compare x y.  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.! connectionsAn  https://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." 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.   !"! "  4444444444Safe&-/58@*W connections3A Galois connection between two monotone functions.W is the mirror image of X: swapR :: ConnL a b -> ConnR b aIf you only require one connection there is no particular reason to use one version over the other.However some use cases (e.g. rounding) require an adjoint triple of connections (i.e. a Y) that can lower into a standard connection in either of two ways.X 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.Each 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 \} For further information see .Caution: Monotonicity is not checked.Y 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 For detailed properties see .Z connectionsAn  ,https://ncatlab.org/nlab/show/adjoint+stringadjoint string( of Galois connections of length 2 or 3.?Connections have many nice properties wrt numerical conversion:range (conn @_ @Rational @Float) (1 :% 8) -- eighths are exactly representable in a float (0.125,0.125)=range (conn @_ @Rational @Float) (1 :% 7) -- sevenths are not(0.14285713,0.14285715)[ connectionsA data kind distinguishing the directionality of a Galois connection:L)-tagged types are low / increasing (e.g.  ,  ,  ,  )R*-tagged types are high / decreasing (e.g.  ,  ,  ,  )^ connectionsA view pattern for a W.Caution:  ConnR f g must obey  f \dashv g  . This condition is not checked._ connectionsA view pattern for a X.Caution:  ConnL f g must obey  f \dashv g  . This condition is not checked.` connections Obtain a Conn. from an adjoint triple of monotone functions.(This is a view pattern for an arbitrary Z. When applied to a X or W, the two functions of type a -> b returned will be identical.Caution:  Conn f g h must obey f \dashv g \dashv h . This condition is not checked.For detailed properties see .a connections The identity Z.b connectionsObtain the center of a Y, upper adjoint of a X, or lower adjoint of a W.c connections7Obtain the upper and/or lower adjoints of a connection. 'range c = floorWith c &&& ceilingWith crange f64f32 pi(3.1415925,3.1415927)range f64f32 (0/0) (NaN,NaN)d connectionsDetermine which half of the interval between 2 representations of a a particular value lies.  d t x =  (x - { t x) (p t x - x)6maybe False (== EQ) $ half f64f32 (midpoint f64f32 pi)Truee connections1Return the midpoint of the interval containing x.pi - midpoint f64f32 pi3.1786509424591713e-8f connectionsReturn the nearest value to x. roundWith identity = idIf x lies halfway between two finite values, then return the value with the larger absolute value (i.e. round away from zero).See  &https://en.wikipedia.org/wiki/Rounding.g connectionsLift a unary function over a Y.?Results are rounded to the nearest value with ties away from 0.h connectionsLift a binary function over a Y.?Results are rounded to the nearest value with ties away from 0.#Example avoiding loss-of-precision:f x y = (x + y) - xmaxOdd32 = 1.6777215e7f maxOdd32 2.0 :: Float1.0 roundWith2 ratf32 f maxOdd32 2.02.0i connectionsTruncate towards zero. truncateWith identity = idj connectionsLift a unary function over a Y.#Results are truncated towards zero. truncateWith1 identity = idl connectionsConvert an inverted X to a X. upL . downL = downL . upL = idm connections Convert a X to an inverted X./upper (downL $ conn @_ @() @Ordering) (Down LT)Down LT/upper (downL $ conn @_ @() @Ordering) (Down GT)Down LTn connections Witness to the symmetry between X and W. %swapL . swapR = id swapR . swapL = ido connectionsReverse round trip through a Y or X.,This is the counit of the resulting comonad: x >~ counit c x!counit (conn @_ @() @Ordering) LTLT!counit (conn @_ @() @Ordering) GTLTp connectionsRound trip through a Y or X. >upper c = upper1 c id = embed c . ceilingWith c x <= upper c xcompare pi $ upper f64f32 piLTq connections Map over a Y or X from the right.r connections Zip over a Y or X from the right.s 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 x meet y is also in b. filterWith and  idealWith commute with Down: 2filterWith c a b <=> idealWith c (Down a) (Down b) 2filterWith c (Down a) (Down b) <=> idealWith c a bfilterWith c a is upward-closed for all a: a <= b1 && b1 <= b2 => a <= b2 ;a1 <= b && inf a2 <= b => ceiling a1 `meet` ceiling a2 <= bSee 2https://en.wikipedia.org/wiki/Filter_(mathematics)t connectionsExtract the left half of a Y or X.floorWith f64f32 pi 3.1415925ceilingWith f64f32 pi 3.1415927u connections Map over a Y or X from the left.v connections Zip over a Y or X from the left.w connectionsConvert an inverted W to a W. upR . downR = downR . upR = idx connections Convert a W to an inverted W./lower (downR $ conn @_ @() @Ordering) (Down LT)Down GT/lower (downR $ conn @_ @() @Ordering) (Down GT)Down GTy connections Witness to the symmetry between X and W. %swapL . swapR = id swapR . swapL = idz connectionsRound trip through a Y or W.(This is the unit of the resulting monad: >x <~ unit c x unit c = floorWith1 c id = floorWith c . embed cunit (conn @_ @() @Ordering) LTGTunit (conn @_ @() @Ordering) GTGT{ connectionsReverse round trip through a Y or W. x >~ lower c xcompare pi $ lower f64f32 piGT| connections Map over a Y or W from the left.} connections Zip over a Y or W from the left.~ 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 x join y is also in B. idealWith c a is downward-closed for all a: a >= b1 && b1 >= b2 => a >= b2 3a1 >= b && a2 >= b => floor a1 `join` floor a2 >= bSee 2https://en.wikipedia.org/wiki/Ideal_(order_theory) connectionsExtract the right half of a Y or W2This is the adjoint functor theorem for preorders.floorWith f64f32 pi 3.1415925ceilingWith f64f32 pi 3.1415927 connections Map over a Y or W from the right. connections Zip over a Y or W from the right. connections Lift two Z s into a Z on the https://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) cd connections Lift two Z s into a Z on the https://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) cd/ WXYZ[]\^_`abcdefghijklmnopqrstuvwxyz{|}~/[]\Z`bcaYdefghijkX_lmnopqrstuvW^wxyz{|}~ SafeAv connectionsCaution: This assumes that  on your system is 64 bits.%%Safe-B connectionsCaution: This assumes that  on your system is 64 bits.Safe-J connectionsA strict preorder relation on a.Is x less than y?, is irreflexive, asymmetric, and transitive. x < 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. x > 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 ArithException 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 ArithException on floats and rationals if one of the arguments is finite and the other is NaN. connections$Compare two values in a total order. x < 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 ArithException 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) !!  4444444444Safe5Nt connectionsAn interval in a poset P.An interval in a poset P is a subset I of P with the following property: \forall x, y \in I, z \in P: x \leq z \leq y \Rightarrow z \in I  connectionsMap over an interval.Note 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 order3Safe58O~ connections"Add a bottom and top to a lattice.The top is the absorbing element for the join, and the bottom is the absorbing element for the meet. connections Eliminate an .   Safe-W connectionsAll  ' values are exactly representable in a . connectionsAll ' values are exactly representable in a . ceilingWith f32i16 32767.03Extended 32767 > ceilingWith f32i16 32767.1 Top connectionsAll  ' values are exactly representable in a . connectionsAll ' values are exactly representable in a . connectionsAll ' values are exactly representable in a . connectionsA NaN-handling min32 function. min32 x NaN = x min32 NaN y = y connectionsA NaN-handling max32 function. max32 x NaN = x max32 NaN y = y connectionsCompute 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 also  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/0NaNshift32 (-1) $ 0/0NaNshift32 1 $ 1/0Infinity connectionsA NaN-handling min function. min64 x NaN = x min64 NaN y = y connectionsA NaN-handling max function. max64 x NaN = x max64 NaN y = y connectionsCompute 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/0NaNshift64 (-1) $ 0/0NaNshift64 1 $ 1/0InfinitySafe-Y  connectionsA total version of !". connectionsShift by n 'units of least precision' where the ULP is determined by the denominatorThis is an analog of  # for rationals. Safe &-/>?k# connectionsAn  ,https://ncatlab.org/nlab/show/adjoint+stringadjoint string( of Galois connections of length 2 or 3. connections*range (conn @_ @Rational @Float) (22 :% 7)(3.142857,3.1428573)!range (conn @_ @Double @Float) pi(3.1415925,3.1415927) connectionsA constraint kind for  conversions.Usable in conjunction with RebindableSyntax: 7fromRational = round :: ConnRational a => Rational -> a connectionsA constraint kind for  conversions.Usable in conjunction with RebindableSyntax:  Integer -> a connections"A constraint kind representing an  ,https://ncatlab.org/nlab/show/adjoint+tripleadjoint triple of Galois connections. connectionsA preorder variant of $%. connectionsA preorder variant of $&. connections$The canonical connections against a . 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 connectionsGreatest lower bound operator. glb 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.0glb (fromList [1..3]) (fromList [3..5]) (fromList [5..7]) :: Set IntfromList [3,5] connectionsReturn the nearest value to x. round @a @a = idIf x lies halfway between two finite values, then return the value with the larger absolute value (i.e. round away from zero).See  &https://en.wikipedia.org/wiki/Rounding. connectionsLift a unary function over a Z.?Results are rounded to the nearest value with ties away from 0. connectionsLift a binary function over a Z.?Results are rounded to the nearest value with ties away from 0.#Example avoiding loss-of-precision:f x y = (x + y) - xmaxOdd32 = 1.6777215e7f maxOdd32 2.0 :: Float1.0&round2 @Rational @Float f maxOdd32 2.02.0maxOdd64 = 9.007199254740991e15f maxOdd64 2.0 :: Double1.0'round2 @Rational @Double f maxOdd64 2.02.0 connectionsTruncate towards zero. truncate @a @a = id connectionsLift a unary function over a Z. Results are truncated towards 0. connectionsLift a binary function over a Z. Results are truncated towards 0. connectionsA specialization of conn to left-side connections.This is a convenience function provided primarily to avoid needing to enable  DataKinds. connectionsExtract the center of a Z or upper half of a X. connections A minimal element of a preorder.% needn't be unique, but it must obey: x <~ minimal => x ~~ minimal connections&Semigroup operation on a join-lattice. connectionsExtract the ceiling of a Z or lower half of a X. ceiling @a @a = id ceiling (x1 `join` a2) = ceiling x1 `join` ceiling x2~ maximal => x ~~ maximal connections&Semigroup operation on a meet-lattice. connectionsExtract the floor of a Y or upper half of a X. floor @a @a = id floor (x1 `meet` x2) = floor x1 `meet` floor x2?% connectionsBoolean algebras. -https://ncatlab.org/nlab/show/Boolean+algebraBoolean algebras 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+Algebra+algebra De Morgan 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 algebrasA Heyting algebra is a bounded, distributive lattice equipped with an implication operation.The complete of closed subsets of a topological space is the primordial example of a  Coheyting (co-Algebra) algebra.The 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 \/ aNote 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-Algebra+algebraHeyting:Implication from a* is the upper adjoint of conjunction with a: x <= a // y <=> a /\ x <= ySimilarly, 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. algebra @'L x = ConnL (\\ x) (\/ x) algebra @'R x = ConnR (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 bounded 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.Note 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). connections1The defining connection of a bounded 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 $ floorWith semilattice connections+The unique top element of a bounded lattice x /\ top = x x \/ top = top connections Lattice join. &(\/) = curry $ ceilingWith semilattice connections.The unique bottom element of a bounded 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+Algebra+algebraDe Morgan conditions. connections The Algebra ( -https://ncatlab.org/nlab/show/excluded+middlenot necessarily excluded) middle operator. connections*Default constructor for a Algebra algebra. connectionsAn 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. connectionsAn 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. connectionsAll minimal elements of the upper lattice cover all maximal elements of the lower lattice. connections(Subdirectly irreducible Algebra algebra.$$46588  Safe-Inferred/ connectionsSee  8https://en.wikipedia.org/wiki/Binary_relation#Properties.Note 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. connectionsCheck a  is internally consistent.This is a required property. connectionsCheck that an ! is internally consistent.This is a required property. connections> \forall a, b: (a \leq b) \wedge (b \leq a) \Rightarrow a = b  is an antisymmetric relation.This is a required property. connections \forall a: (a \leq a)  is a reflexive relation.This is a required property. connections \forall a, b, c: ((a \leq b) \wedge (b \leq c)) \Rightarrow (a \leq c)  is an transitive relation.This is a required property. connections, \forall a, b: ((a \leq b) \vee (b \leq a))  is a connex relation. connections4 \forall a, b: (a \lt b) \Rightarrow \neg (b \lt a) lt is an asymmetric relation.This is a required property. connections \forall a: \neg (a \lt a) lt is an irreflexive relation.This is a required property. connections \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. connections \forall a, b: \neg (a = b) \Rightarrow ((a \lt b) \vee (b \lt a)) lt is a semiconnex relation. connections \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. connections \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. connections/ \forall a, b: (a = b) \Leftrightarrow (b = a)  is a symmetric relation.This is a required property. connections \forall a: (a = a)  is a reflexive relation.This is a required property connections? \forall a, b, c: ((a = b) \wedge (b = c)) \Rightarrow (a = c)  is a transitive relation.This is a required property. connections \forall a: (a \# a) 4For example, D is a reflexive relation but > is not. connections \forall a: \neg (a \# a) 8For example, > is an irreflexive relation, but D is not. connections \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. connections? \forall a, b: (a \# b) \Rightarrow ((a \# a) \wedge (b \# b))  connections \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. connections \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. connections \forall a, b, c: ((a \# b) \wedge (b \# c)) \Rightarrow (a \# c) For example, "is ancestor of" is a transitive relation, while "is parent of" is not. connections( \forall a, b: ((a \# b) \vee (b \# a)) For example, D is a connex relation, while 'divides evenly' is not.A connex relation cannot be symmetric, except for the universal relation. connections \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.A relation is connex if and only if it is semiconnex and reflexive. connections \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 D 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 D is not.A 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 For example, D is an antisymmetric relation; so is >, but vacuously (the condition in the definition is always false).""10  Safe-Inferred>?_;;Safeh WXYZ[]\^_`abcdefghijklmnopqrstuvwxyz{|}~ Safe-Inferred -/  connections \forall x, y : f \dashv g \Rightarrow f (x) \leq y \Leftrightarrow x \leq g (y) A Galois connection is an adjunction of preorders. This is a required property. 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. connections6 \forall x, y : x \leq y \Rightarrow f (x) \leq f (y) This is a required property. connections \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 connections3 \forall a, b: a \leq b \Rightarrow f(a) \leq f(b)  connections3 \forall a, b: a \leq b \Rightarrow f(b) \leq f(a)  connections2 \forall a: f a \leq b \Leftrightarrow a \leq g b 8For example, a monotone Galois connection is defined by adjunction (<~) (<~)3, and an antitone Galois connection is defined by adjunction (>~) (<~). connections \forall a: f (g a) \sim a  connections% \forall a: g \circ f (a) \sim f (a) %idempotent (#) f = projective (#) f f*+,*+-*./0!10!2*.3*.4*.506070708908:;<<=>>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~           #      "                                                                                                                                                                                                                     )                                                                                                                                                                         *+*+00*.*.*.0*.00!*.(connections-0.2.0-DeRRGdWJkv66Qly2VHCKTZData.Order.Syntax Data.OrderData.Connection.RatioData.Connection.ConnData.Connection.WordData.Connection.IntData.Order.IntervalData.Order.ExtendedData.Connection.FloatData.Connection.Class Data.LatticeData.Order.PropertyData.Lattice.PropertyData.Connection.PropertyData.OrdmaxmincompareData.Order.Total comparingData.ConnectionPropertyminimalupperceilingjoinmaximallowerfloormeetData.IntInt08GHC.Realreduceshift32 Control.Arrow|||&&&Data.SetSet\\ghc-prim GHC.ClassesEqOrd GHC.TypesOrderingbaseRatio:%LTEQGTgetDownDownControl.Category>>><<<PositiveN5getN5BasegetBasePreorder<~>~?~~~/~pltpgtsimilarpmaxpminpcompareTotalOrder pcomparing$fPreorderIntSet$fPreorderIntMap $fPreorderSet $fPreorderMap$fPreorder(,,,,)$fPreorder(,,,)$fPreorder(,,) $fPreorder(,)$fPreorderEither$fPreorderNonEmpty $fPreorder[]$fPreorderMaybe$fPreorderIdentity $fPreorderAll $fPreorderAny $fPreorderMin $fPreorderMax$fPreorderDual$fPreorderDown$fPreorderComplex$fPreorderRatio$fPreorderBase $fPreorderN5$fPreorderRatio0$fEqN5$fShowN5 $fFunctorN5$fApplicativeN5$fEqBase $fOrdBase $fShowBase $fFunctorBase$fApplicativeBase$fPreorderDouble$fPreorderFloat$fPreorderInteger$fPreorderInt64$fPreorderInt32$fPreorderInt16$fPreorderInt8 $fPreorderInt$fPreorderNatural$fPreorderWord64$fPreorderWord32$fPreorderWord16$fPreorderWord8$fPreorderWord$fPreorderChar$fPreorderOrdering$fPreorderBool $fPreorder()$fPreorderVoidConnRConnLConnKConnKanLRidentityembedrangehalfmidpoint roundWith roundWith1 roundWith2 truncateWith truncateWith1 truncateWith2upLdownLswapLcounitupper1upper2 filterWith ceilingWith ceilingWith1 ceilingWith2upRdownRswapRunitlower1lower2 idealWith floorWith floorWith1 floorWith2choicestrong$fCategoryTYPEConni08w08w08w16i08w16i16w16w08w32w16w32i08w32i16w32i32w32w08w64w16w64w32w64i08w64i16w64i32w64i64w64ixxw64w08wxxw16wxxw32wxxw64wxxi08wxxi16wxxi32wxxi64wxxixxwxxw08natw16natw32natw64natwxxnati08nati16nati32nati64natixxnatintnatw08i16i08i16w08i32w16i32i08i32i16i32w08i64w16i64w32i64i08i64i16i64i32i64w08ixxw16ixxw32ixxi08ixxi16ixxi32ixxi64ixxw08intw16intw32intw64intwxxintnatinti08inti16inti32inti64intixxint<>==/=<=>=Intervalimap...iempty singletonendptscontains$fPreorderInterval $fEqInterval$fShowIntervalExtendedBottomTopLoweredLiftedextended liftMaybe liftEitherL liftEitherR liftExtended$fPreorderExtended $fEqExtended $fOrdExtended$fShowExtended$fGenericExtended$fFunctorExtended$fGeneric1TYPEExtendedf32i08f32i16f64i08f64i16f64i32f64f32min32max32ulp32near32min64max64ulp64near64shift64untilshiftdrati08rati16rati32rati64ratixxratintratf32ratf64posw08posw16posw32posw64poswxxposnat Connectionconn ConnExtended ConnRational ConnIntegerTripleRightLeft\|//|\extremallubglbroundround1round2truncate truncate1 truncate2connLembedLceiling1ceiling2connRembedRfloor1floor2$fConnectionL()IntMap$fConnectionL()Map$fConnectionk(,)IntSet$fConnectionL()IntSet$fConnectionk(,)Set$fConnectionL()Set$fConnectionk()Extended$fConnectionL()Maybe$fConnectionkaIdentity$fConnectionkIdentityb$fConnectionkDoubleExtended$fConnectionkDoubleExtended0$fConnectionkDoubleExtended1$fConnectionkFloatExtended$fConnectionkFloatExtended0$fConnectionkRatioExtended$fConnectionkRatioExtended0$fConnectionkRatioExtended1$fConnectionkRatioExtended2$fConnectionkRatioExtended3$fConnectionkRatioExtended4$fConnectionLIntMaybe$fConnectionLInt64Maybe$fConnectionLInt32Maybe$fConnectionLInt16Maybe$fConnectionLInt8Maybe$fConnectionLNaturalMaybe$fConnectionLWordMaybe$fConnectionLWord64Maybe$fConnectionLWord32Maybe$fConnectionLWord16Maybe$fConnectionLWord8Maybe$fConnectionkInt64Int$fConnectionLInt32Maybe0$fConnectionLInt16Maybe0$fConnectionLInt8Maybe0$fConnectionLWord32Maybe0$fConnectionLWord16Maybe0$fConnectionLWord8Maybe0$fConnectionLInt32Maybe1$fConnectionLInt16Maybe1$fConnectionLInt8Maybe1$fConnectionLWord32Maybe1$fConnectionLWord16Maybe1$fConnectionLWord8Maybe1$fConnectionLInt16Maybe2$fConnectionLInt8Maybe2$fConnectionLWord16Maybe2$fConnectionLWord8Maybe2$fConnectionLInt8Maybe3$fConnectionLWord8Maybe3$fConnectionk(,)Double$fConnectionkRatioDouble$fConnectionk()Double$fConnectionk(,)Float$fConnectionkRatioFloat$fConnectionkDoubleFloat$fConnectionk()Float$fConnectionk(,)Ratio$fConnectionk()Ratio$fConnectionk(,)Integer$fConnectionk(,)Int$fConnectionk()Int$fConnectionk(,)Int64$fConnectionk()Int64$fConnectionk(,)Int32$fConnectionk()Int32$fConnectionk(,)Int16$fConnectionk()Int16$fConnectionk(,)Int8$fConnectionk()Int8$fConnectionk(,)Ratio0$fConnectionk()Ratio0$fConnectionk(,)Natural$fConnectionLIntegerNatural$fConnectionLIntNatural$fConnectionLInt64Natural$fConnectionLInt32Natural$fConnectionLInt16Natural$fConnectionLInt8Natural$fConnectionLWordNatural$fConnectionLWord64Natural$fConnectionLWord32Natural$fConnectionLWord16Natural$fConnectionLWord8Natural$fConnectionL()Natural$fConnectionk(,)Word$fConnectionLIntWord$fConnectionLInt64Word$fConnectionLInt32Word$fConnectionLInt16Word$fConnectionLInt8Word$fConnectionkWord64Word$fConnectionLWord32Word$fConnectionLWord16Word$fConnectionLWord8Word$fConnectionk()Word$fConnectionk(,)Word64$fConnectionLIntWord64$fConnectionLInt64Word64$fConnectionLInt32Word64$fConnectionLInt16Word64$fConnectionLInt8Word64$fConnectionLWord32Word64$fConnectionLWord16Word64$fConnectionLWord8Word64$fConnectionk()Word64$fConnectionk(,)Word32$fConnectionLInt32Word32$fConnectionLInt16Word32$fConnectionLInt8Word32$fConnectionLWord16Word32$fConnectionLWord8Word32$fConnectionk()Word32$fConnectionk(,)Word16$fConnectionLInt16Word16$fConnectionLInt8Word16$fConnectionLWord8Word16$fConnectionk()Word16$fConnectionk(,)Word8$fConnectionLInt8Word8$fConnectionk()Word8$fConnectionk(,)Ordering$fConnectionk()Ordering$fConnectionk(,)Bool$fConnectionkDoubleBool$fConnectionkFloatBool$fConnectionkRatioBool$fConnectionkIntBool$fConnectionkInt64Bool$fConnectionkInt32Bool$fConnectionkInt16Bool$fConnectionkInt8Bool$fConnectionkRatioBool0$fConnectionkWordBool$fConnectionkWord64Bool$fConnectionkWord32Bool$fConnectionkWord16Bool$fConnectionkWord8Bool$fConnectionkOrderingBool$fConnectionk()Bool$fConnectionk(,)()$fConnectionkaa$fConnectionR(,)IntMap$fConnectionR(,)Map$fConnectionR()Either$fConnectionR()Maybe$fConnectionL(,)IntMap$fConnectionL(,)Map$fConnectionL()Either$fConnectionkMaybeEither$fConnectionkMaybeEither0$fConnectionk()(,)Booleanboolean SymmetricnotxorAlgebraalgebra Biheyting CoheytingHeyting Semilatticebounded semilatticeMeetJoinLattice/\top\/bottom//iffnegmiddleheytingbooleanRequivnonboundary coheytingbooleanL converseL converseR symmetricR symmetricL$fSemilatticeLIntSet$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$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(,)$fSymmetric(,)$fSymmetricOrdering$fSymmetricBool $fSymmetric() $fBoolean(,)$fBooleanOrdering $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 antisymmetric coheyting0 coheyting1 coheyting2 coheyting3 coheyting4 coheyting5 coheyting6 coheyting7 coheyting8 coheyting9 coheyting10 coheyting11 coheyting12 coheyting13 coheyting14 coheyting15 coheyting16 coheyting17 coheyting18 coheyting19 coheyting20heyting0heyting1heyting2heyting3heyting4heyting5heyting6heyting7heyting8heyting9 heyting10 heyting11 heyting12 heyting13 heyting14 heyting15 heyting16 heyting17 symmetric1 symmetric2 symmetric3 symmetric4 symmetric5 symmetric6 symmetric7 symmetric8 symmetric9 symmetric10 symmetric11 symmetric12 symmetric13boolean0boolean1boolean2boolean3boolean4boolean5boolean6adjointadjointLadjointRclosedclosedLclosedRkernelkernelLkernelR monotonic monotonicR monotonicL idempotent idempotentL idempotentRmonotoneantitone adjunction invertible projective|| GHC.MaybeJustGHC.Base$WordIntFloatGHC.IntInt16DoubleInt32Rationalinteger-wired-inGHC.Integer.TypeIntegerBool