• Can CLAM do bidrectional rounding? (Was: Australian Longest Straight Road in Prolog)

    From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Mon Jul 14 16:15:51 2025
    From Newsgroup: comp.lang.prolog

    The conversion factor in the units database is:

    ?- qeval(X*1 is mi/km).
    X = 1.609344.

    I had first used 1.60934, but then used
    1.609344. But I think this here is not a
    symmetric answer, and a symmetric answer
    using constraint logic programming

    maybe impossible:

    ?- qeval((145.6*km =:= 90*usc:mile+quantity Eps, SIEps is Eps in km)).
    Eps = 0.4716455897558234*kind_of(isq:length)[usc:mile],
    SIEps = 0.7590399999999958*kind_of(isq:length)[si:kilo(si:metre)].

    Do you have intervals associated with
    units, so you can write rCLin kmrCY?

    I computes 145.6*km - 90*mile in terms of km, so it computes:

    /* Windows 11 Calcultator */
    145.6 - 90*1.609344 = 0.75904

    /* SWI-Prolog Evaluator */
    ?- X is 145.6 - 90*1.609344.
    X = 0.7590399999999988

    So to be correctly rounded to one digit after
    the period, the eps would need to be smaller. But for
    the other direction, whether the conversion
    from km to mile was correct, I guess a

    2nd query would be needed. But still I would
    be interested whether constraint logic programming
    can answer such questions in one query, like
    whether CLAM (the idea of Constraint Logic

    Abstract Machines) has a rounding bidirectionality?
    Giving new momentum to the dream that
    CLAM is a silver bullet.

    Mild Shock schrieb:
    Do these units packages define rounding? Is this correct:

    https://www.shutterstock.com/de/image-photo/road-sign-longest-straight-australia-548866177


    I think one way its correct:

    145.6 km |+ 1.609344 km/mile = 90.47 miles

    The other way its incorrect:

    90 miles |u 1.609344 km/mile = 144.84 km

    Mild Shock schrieb:
    Hi,

    So how does academic purity compare to industrial
    success? Well this talk by Martin Odersky has some
    interesting slides comparing past and present:

    Evolving Scala by Martin Odersky | Scalar Conference 2025
    https://www.youtube.com/watch?v=DI0NOh9r1f8

    Where Scala ranked in 2014, versus where Scala
    ranks in 2025. Haskell gone, Clojure gone.

    LoL

    Bye

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Tue Jul 15 01:26:20 2025
    From Newsgroup: comp.lang.prolog

    Hi,

    My recent thinking is such rounding could have
    a place in CLAM (Constraint Logic Abstract Machine),
    as part of some interval arithmetic. Particularly
    pointed intervals, like 145.6 is basically the
    interval [145.55 .. 145.65),

    including the lower bound excluding the upper bound.
    The value 145.6 is associated with the interval, and
    not some midpoint, has to do that the rounded value is
    the associated point. So all values in the interval round to

    the associated rounded value. But I didnrCOt do a thorough
    research yet. It would basically give a different rationalize
    and associated interval computation from input, a more business
    like rationalize that requires that the number

    scanner tokenizer also records the number of fractional
    digits in the input. So that for example 90 and 90.0 are
    not the same when it comes to rationalize and associated
    interval computation from some given input.

    Most fixnum rounding have midpoint = rounded value:

    145.6 ~~> [145.55 .. 145.65) ~~> (145.55 + 145.65) = 145.6
    90 ~~> [89.5 ..90.5) ~~> (89.5 + 90.5) = 90

    But some rounding, like for example automatically
    choosing a scale, i.e. going from bytes to kilo bytes,
    mega bytes, giga bytes etc.., many directory listings
    can do that when they show a file size,

    I guess the associated intervals and
    rounded values are more exotic.

    Bye

    Mild Shock schrieb:
    The conversion factor in the units database is:

    ?- qeval(X*1 is mi/km).
    X = 1.609344.

    I had first used 1.60934, but then used
    1.609344. But I think this here is not a
    symmetric answer, and a symmetric answer
    using constraint logic programming

    maybe impossible:

    ?- qeval((145.6*km =:= 90*usc:mile+quantity Eps, SIEps is Eps in km)).
    Eps = 0.4716455897558234*kind_of(isq:length)[usc:mile],
    SIEps = 0.7590399999999958*kind_of(isq:length)[si:kilo(si:metre)].

    Do you have intervals associated with
    units, so you can write rCLin kmrCY?

    I computes 145.6*km - 90*mile in terms of km, so it computes:

    /* Windows 11 Calcultator */
    145.6 - 90*1.609344 = 0.75904

    /* SWI-Prolog Evaluator */
    ?- X is 145.6 - 90*1.609344.
    X = 0.7590399999999988

    So to be correctly rounded to one digit after
    the period, the eps would need to be smaller. But for
    the other direction, whether the conversion
    from km to mile was correct, I guess a

    2nd query would be needed. But still I would
    be interested whether constraint logic programming
    can answer such questions in one query, like
    whether CLAM (the idea of Constraint Logic

    Abstract Machines) has a rounding bidirectionality?
    Giving new momentum to the dream that
    CLAM is a silver bullet.

    Mild Shock schrieb:
    Do these units packages define rounding? Is this correct:

    https://www.shutterstock.com/de/image-photo/road-sign-longest-straight-australia-548866177


    I think one way its correct:

    145.6 km |+ 1.609344 km/mile = 90.47 miles

    The other way its incorrect:

    90 miles |u 1.609344 km/mile = 144.84 km

    Mild Shock schrieb:
    Hi,

    So how does academic purity compare to industrial
    success? Well this talk by Martin Odersky has some
    interesting slides comparing past and present:

    Evolving Scala by Martin Odersky | Scalar Conference 2025
    https://www.youtube.com/watch?v=DI0NOh9r1f8

    Where Scala ranked in 2014, versus where Scala
    ranks in 2025. Haskell gone, Clojure gone.

    LoL

    Bye


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Tue Jul 15 01:28:01 2025
    From Newsgroup: comp.lang.prolog

    Typo: Forgot division by two:

    145.6 ~~> [145.55 .. 145.65) ~~> (145.55 + 145.65) = 145.6
    90 ~~> [89.5 ..90.5) ~~> (89.5 + 90.5) = 90

    Should read:

    145.6 ~~> [145.55 .. 145.65) ~~> (145.55 + 145.65)/2 = 145.6
    90 ~~> [89.5 ..90.5) ~~> (89.5 + 90.5)/2 = 90


    Mild Shock schrieb:
    Hi,

    My recent thinking is such rounding could have
    a place in CLAM (Constraint Logic Abstract Machine),
    as part of some interval arithmetic. Particularly
    pointed intervals, like 145.6 is basically the
    interval [145.55 .. 145.65),

    including the lower bound excluding the upper bound.
    The value 145.6 is associated with the interval, and
    not some midpoint, has to do that the rounded value is
    the associated point. So all values in the interval round to

    the associated rounded value. But I didnrCOt do a thorough
    research yet. It would basically give a different rationalize
    and associated interval computation from input, a more business
    like rationalize that requires that the number

    scanner tokenizer also records the number of fractional
    digits in the input. So that for example 90 and 90.0 are
    not the same when it comes to rationalize and associated
    interval computation from some given input.

    Most fixnum rounding have midpoint = rounded value:

    145.6 ~~> [145.55 .. 145.65) ~~> (145.55 + 145.65) = 145.6
    90-a-a-a ~~> [89.5 ..90.5)-a-a-a-a-a ~~> (89.5 + 90.5) = 90

    But some rounding, like for example automatically
    choosing a scale, i.e. going from bytes to kilo bytes,
    mega bytes, giga bytes etc.., many directory listings
    can do that when they show a file size,

    I guess the associated intervals and
    rounded values are more exotic.

    Bye

    Mild Shock schrieb:
    The conversion factor in the units database is:

    ?- qeval(X*1 is mi/km).
    X = 1.609344.

    I had first used 1.60934, but then used
    1.609344. But I think this here is not a
    symmetric answer, and a symmetric answer
    using constraint logic programming

    maybe impossible:

    ?- qeval((145.6*km =:= 90*usc:mile+quantity Eps, SIEps is Eps in km)).
    Eps = 0.4716455897558234*kind_of(isq:length)[usc:mile],
    SIEps = 0.7590399999999958*kind_of(isq:length)[si:kilo(si:metre)].

    Do you have intervals associated with
    units, so you can write rCLin kmrCY?

    I computes 145.6*km - 90*mile in terms of km, so it computes:

    /* Windows 11 Calcultator */
    145.6 - 90*1.609344 = 0.75904

    /* SWI-Prolog Evaluator */
    ?- X is 145.6 - 90*1.609344.
    X = 0.7590399999999988

    So to be correctly rounded to one digit after
    the period, the eps would need to be smaller. But for
    the other direction, whether the conversion
    from km to mile was correct, I guess a

    2nd query would be needed. But still I would
    be interested whether constraint logic programming
    can answer such questions in one query, like
    whether CLAM (the idea of Constraint Logic

    Abstract Machines) has a rounding bidirectionality?
    Giving new momentum to the dream that
    CLAM is a silver bullet.

    Mild Shock schrieb:
    Do these units packages define rounding? Is this correct:

    https://www.shutterstock.com/de/image-photo/road-sign-longest-straight-australia-548866177


    I think one way its correct:

    145.6 km |+ 1.609344 km/mile = 90.47 miles

    The other way its incorrect:

    90 miles |u 1.609344 km/mile = 144.84 km

    Mild Shock schrieb:
    Hi,

    So how does academic purity compare to industrial
    success? Well this talk by Martin Odersky has some
    interesting slides comparing past and present:

    Evolving Scala by Martin Odersky | Scalar Conference 2025
    https://www.youtube.com/watch?v=DI0NOh9r1f8

    Where Scala ranked in 2014, versus where Scala
    ranks in 2025. Haskell gone, Clojure gone.

    LoL

    Bye



    --- Synchronet 3.21a-Linux NewsLink 1.2