-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solving Unit-1 is-equivalent-to Unit-2 #89
Comments
So I'd conclude, for any implementers to consider
|
Thanks for pointing that out. Either for the Spec or UoM Guidebook I assume some of this information will also help. |
I propose an amendment to the first point:
For example kilometre and kilowatt have the same I agree that implementations should produce normal forms. In the case of unit conversions, this is simplified by the fact that the vast majority of conversions are linear, in which case commutativity (among other) applies. However one difficulty we have with current API is that
It is not the usual definition of linear conversion since a converter of the form y = scale * x + offset would not comply to this definition. This prevent implementations to detect e.g. that commutativity applies for Celsius units for instance. |
@desruisseaux thanks for the hint, I've updated the description. |
Regarding |
We could add new methods but should not remove any without deprecating them first. Pulling MetricPrefix from the RI into the API was already a bit of a challenge but i was not removed and the package name also changed, so existing code may be migrated with little changes to impor statements. Completely removing a method would only work another version down the road. |
Sorry, I did not mean to start a naming discussion. |
Actually @desruisseaux started it already #39 |
@andi-huber Is there anything to do here? |
I think we can close this. |
Thanks |
Quick Facts
Unit
must hold an instance ofUnitConverter
.UnitConverters
represent transformations.UnitConverters
allow composition, such that composing 2UnitConverters
is equivalent to composing their transformation functions.UnitConverters
of same type can be equivalent but are not in general, e.g. they may not be equivalent because of different prefix.Suppose we have
UnitConverter
types A,B,C.Let S be the set of
UnitConverter
types available.S:= {A,B,C}
Now if we pick any
x
and anyy
fromS
we need to knowx
commutes withy
, such that a composition x.y is equivalent to y.xx.y =?= y.x
x.y
->x
orx.y
->y
or similar.Given this information we are ready to state a
Word Problem
[1] for any given pair of Units, for example:Suppose we know A commutes with B, but C does not commute with any other
A.B == B.A
A.C != C.A
B.C != C.B
Suppose we know C composes with C, such that C.C can be simplified to another C
C.C -> C
Suppose we have a UnitConverter
p
created by composition of types A, B and C (namely a0, b0 and c0).p:= b0.a0.c0 (with type composition B.A.C)
Suppose we have a UnitConverter
q
created by another composition of types A, B and C (namely a2, b2, c1 and c2).q:= a2.b2.c1.c2 (with type composition A.B.C.C)
We would then apply
Term Rewriting
rules to the type compositions ofp
andq
until we find that these are equivalent (or not). Ideally we have such rules that produce anormal form
.p: B.A.C -> A.B.C
q: A.B.C.C -> A.B.C
Given
p: a0.b0.c0
q: a2.b2.(c1.c2)
then
p
is-equivalent-toq
, only if all these hold truea0 is-equivalent-to a2
b0 is-equivalent-to b2
c0 is-equivalent-to c1.c2
If the
Term Rewriting
rules are carefully designed to always produce anormal form
, then the Unit-1 is-equivalent-to Unit-2 problem is decidable. Otherwise it's not for the general case.[1] https://en.wikipedia.org/wiki/Word_problem_(mathematics)
Needs #39
The text was updated successfully, but these errors were encountered: