unit_ex.n3 1.33 KB
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix un:	<http://www.w3.org/2007/ont/unit#> .
@prefix math:	<http://www.w3.org/2000/10/swap/math#>.
@prefix o2:  <http://www.w3.org/2007/ont/o2#>.

@prefix   : <unit_ex#>.
@prefix ex: <unit_ex#>.

@keywords a, is, of.

# numeric multiplication associates with unit multiplication
{ (?U1 ?S1) un:product ?U2.
  (?U2 ?S2) un:product ?U3.
  (?S1 ?S2) math:product ?S3
} => { (?U1 ?S3) un:product ?U3 }.

# scalar conversions between units
{ ?X ?UNIT ?V.
  (?BASE ?CONVERSION) un:product ?UNIT.
  (?V ?CONVERSION) math:product ?V2.
} => { ?X ?BASE ?V2 }.


# property chaining: shortening
{ ?S ?P1 [ ?P2 ?O].
  (?P1 ?P2) o2:chain ?P3
} => { ?S ?P3 ?O }.


# normalizing unit chains by expansion:
# (hmm... this would work better if derived
# units were defined by chaining one property
# at the beginning of the list each time, I think).
{ ?U1 a un:Unit; is o2:chain of (?U2 ?U).
  ?U2 is o2:chain of (?U3 ?U4).
} => { ?U1 is o2:chain of (?U3 ?U4 ?U) }.


# pushing conversion factors into chains, one case:
{
  (?BASIC ?CONVERSION) un:product ?DERIVED.
  (?BASIC ?U1) o2:chain ?UCB.
  (?DERIVED ?U1) o2:chain ?UCD.
} => { (?UCB ?CONVERSION) un:product ?UCD }.


# examples...

# test for scalar conversions
track length [ un:mile 0.25].

# test for inverses
(un:foot un:hz) o2:chain fps.
bullet speed [ fps 4000 ].