# =====================================================================
#  Jev -> Decision Model Bridge  (inference.ttl)
#
#  Layer 3 of 3:
#      decision-making.ttl   general semantics of decisions
#      jev.ttl               native Jev / System One vocabulary
#      inference.ttl         semantic bridge between the two  <- THIS FILE
#
#  Loading all three files into an RDFS/OWL reasoner makes a graph written
#  entirely in jev: terms readable in generic dm: terms, without either
#  core ontology depending on the other.
#
#  Hygiene: a bridge ontology adds AXIOMS ABOUT existing terms; it never
#  mints new terms in a namespace it does not own. The few individuals
#  declared here therefore live in this ontology's own namespace (jevx:).
# =====================================================================

@prefix dm:      <https://www.openlinksw.com/ontology/decision-model#> .
@prefix jev:     <https://www.openlinksw.com/ontology/jev#> .
@prefix jevx:    <https://www.openlinksw.com/ontology/jev/inference#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
@prefix skos:    <http://www.w3.org/2004/02/skos/core#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix vann:    <http://purl.org/vocab/vann/> .

# ---------------------------------------------------------------------
# Ontology header
# ---------------------------------------------------------------------

<https://www.openlinksw.com/ontology/jev/inference>
    a owl:Ontology ;
    owl:versionIRI <https://www.openlinksw.com/ontology/jev/inference/1.0.0> ;
    owl:imports
        <https://www.openlinksw.com/ontology/decision-model> ,
        <https://www.openlinksw.com/ontology/jev> ;
    dcterms:title "Jev to Decision Model Mapping"@en ;
    dcterms:description """The semantic alignment between the Jev ontology and the vendor-neutral Decision Model ontology.

This file contains only mapping axioms and the canonical individuals that describe Jev as an execution backend. It is the only one of the three files that mentions both namespaces, and it is the only one that has to change when either side evolves."""@en ;
    dcterms:creator <https://www.openlinksw.com#this>, <https://github.com/danielhmills#this> ;
    dcterms:created "2026-09-20"^^xsd:date ;
    dcterms:license <https://creativecommons.org/licenses/by/4.0/> ;
    vann:preferredNamespacePrefix "jevx" ;
    vann:preferredNamespaceUri "https://www.openlinksw.com/ontology/jev/inference#" ;
    skos:scopeNote """Import strategy. decision-making.ttl and jev.ttl import nothing: each is independently loadable, citable and versionable, and a site that uses only one of them pays nothing for the other. This bridge imports both, so a single owl:imports of <https://www.openlinksw.com/ontology/jev/inference> pulls in the complete three-file system.

Any other backend follows the same pattern with its own pair of files -- foo.ttl plus foo-mapping.ttl -- and decision-making.ttl never changes.

Reasoning profile. Every mapping below that carries semantic weight is an rdfs:subClassOf or rdfs:subPropertyOf axiom, so the intended entailments are available under plain RDFS. The two owl:propertyChainAxiom statements in section 3 need an OWL 2 RL/DL reasoner; equivalent SPARQL CONSTRUCTs are given alongside for stores whose rule sets stop at RDFS-Plus, including OpenLink Virtuoso."""@en .

# =====================================================================
# 1. CLASS MAPPINGS
#
#    All are rdfs:subClassOf, none is owl:equivalentClass. The generic
#    classes are strictly broader: dm:CategoricalDecision also covers an
#    ONNX classifier head, a SPARQL VALUES lookup and a rules engine
#    dispatch table. Asserting equivalence would silently type every
#    categorical decision anywhere as a Jev question, which is false and
#    would corrupt any capability query built on the model.
# =====================================================================

# A Jev question IS a decision specification. It carries the question put
# to the inference system, the admissible answers, and nothing about how
# the answer is produced -- which is precisely dm:Decision's remit.
jev:Question   rdfs:subClassOf dm:Decision .

# The three primitives, mapped to the three core decision types.
jev:Choice     rdfs:subClassOf dm:CategoricalDecision .
jev:Score      rdfs:subClassOf dm:OrdinalDecision .
jev:Noul       rdfs:subClassOf dm:BinaryDecision .

# A Jev level is a point on an ordered scale.
jev:Level      rdfs:subClassOf dm:ScaleValue .

# A Jev answer is the outcome of executing a decision on one occasion.
jev:Answer     rdfs:subClassOf dm:DecisionResult .

# A probabilities entry is one cell of a per-alternative distribution.
jev:ProbabilityEntry rdfs:subClassOf dm:OutcomeScore .

# A System One model is a model artefact in the general sense.
jev:Model      rdfs:subClassOf dm:Model .

# --- Deliberate non-mappings, recorded so they are not re-litigated ----
#
# jev:Evaluation is NOT a dm:DecisionBinding. A binding is a standing
# configuration -- this decision may be run by that backend -- while an
# evaluation is a single past event. They differ in cardinality, lifetime
# and modality. jev:Evaluation is already a prov:Activity in jev.ttl, which
# is the correct generic reading of it; the decision model does not define
# an execution-event class, so there is nothing to map it to.
#
# jev:ChoiceAnswer / jev:ScoreAnswer / jev:NoulAnswer need no mapping of
# their own: they inherit jev:Answer rdfs:subClassOf dm:DecisionResult.

# =====================================================================
# 2. PROPERTY MAPPINGS
#
#    Each is justified by compatible semantics, not by a similar name.
#    Sub-property, not equivalence, for the same reason as above: the
#    generic property has values that no Jev graph will ever produce.
# =====================================================================

# The Jev instructions field is the human-readable question put to the
# model. Same role, same literal value space.
jev:instructions rdfs:subPropertyOf dm:question .

# A Jev option and a dm:option are both an admissible alternative of the
# decision, identified by IRI. Neither property constrains what kind of
# resource that may be, so nothing is lost or over-claimed.
jev:option       rdfs:subPropertyOf dm:option .

# A Score level is an admissible point on the decision's scale. dm:scalePoint
# is the inline form of dm:scale/dm:scaleValue, so this mapping places Jev's
# question-local levels and an organisation's reusable scale in one query.
jev:level        rdfs:subPropertyOf dm:scalePoint .

# A level's array index is its rank on the scale.
jev:levelIndex   rdfs:subPropertyOf dm:position .

# Answer to a question == result of a decision.
jev:answerTo     rdfs:subPropertyOf dm:resultOf .

# The selected option, IRI preserved on both sides.
jev:choice       rdfs:subPropertyOf dm:selectedValue .

# The Score value is the numeric quantity this result reports. Its units are
# level indices rather than a domain quantity; the scale needed to read it is
# reachable through dm:resultOf and the decision's scale points.
jev:score        rdfs:subPropertyOf dm:numericValue .

# Both are the peakedness of the answer's distribution on a 0 to 1 range,
# and both are meant to gate action rather than to express belief in an
# outcome. Reported by Choice and Score answers only.
jev:confidence   rdfs:subPropertyOf dm:confidence .

# One cell of the distribution, and the alternative it scores.
jev:probabilities rdfs:subPropertyOf dm:outcomeScore .
jev:outcome       rdfs:subPropertyOf dm:scoredValue .
jev:probability   rdfs:subPropertyOf dm:probability .

# A Noul value is the probability that the proposition is true.
#
# IT IS MAPPED TO dm:probability AND EXPLICITLY NOT TO dm:confidence.
# The names invite the opposite mapping and the opposite mapping is wrong:
# Jev reports no confidence for a Noul, and a Noul of 0.5 is a maximally
# UNCERTAIN answer, which under dm:confidence would read as moderately
# certain. Any threshold, dashboard or abstention policy built on the
# mistaken mapping would misread the model exactly where it matters most.
jev:noul         rdfs:subPropertyOf dm:probability .

# Model identity.
jev:modelIdentifier rdfs:subPropertyOf dm:modelIdentifier .

# --- Deliberate non-mappings ------------------------------------------
#
# jev:questionId      wire handle; already rdfs:subPropertyOf dcterms:identifier.
# jev:key             a JSON serialisation detail of Jev's encoding, with no
#                     counterpart in a vocabulary about decisions.
# jev:trueCriterion   descriptions of the two outcomes of a Noul. The decision
# jev:falseCriterion  model has no term for these, and inventing dm:trueMeaning
#                     merely to complete the table would grow the core
#                     vocabulary for one backend's benefit. Left unmapped.
# jev:state           the serialised text actually sent. dm:inputResource
#                     records WHICH resource was judged, which is the durable
#                     fact; the serialisation is Jev's business.
# jev:inputTokens     cost accounting, out of scope for the decision model.
# jev:outputTokens
# jev:asked           call composition, out of scope for the decision model.
# jev:producedAnswer

# =====================================================================
# 3. BRIDGING AXIOMS OVER CHAINS
#
#    Jev records provenance on the evaluation, one level away from the
#    answer. These two axioms close that gap so that the generic
#    provenance questions -- which model produced this, which resource is
#    it about -- are answerable directly from the result, as the decision
#    model expects.
#
#    Note that these axioms are stated HERE, about dm: properties, without
#    editing decision-making.ttl. That is the extension point every future
#    provider mapping uses.
# =====================================================================

# dm:generatedBy(answer, model) <- jev:fromEvaluation(answer, eval), jev:model(eval, model)
#   SPARQL equivalent:
#   CONSTRUCT { ?a dm:generatedBy ?m } WHERE { ?a jev:fromEvaluation/jev:model ?m }
dm:generatedBy   owl:propertyChainAxiom ( jev:fromEvaluation jev:model ) .

# dm:inputResource(answer, subject) <- jev:fromEvaluation(answer, eval), jev:stateOf(eval, subject)
#   SPARQL equivalent:
#   CONSTRUCT { ?a dm:inputResource ?r } WHERE { ?a jev:fromEvaluation/jev:stateOf ?r }
dm:inputResource owl:propertyChainAxiom ( jev:fromEvaluation jev:stateOf ) .

# =====================================================================
# 4. CAPABILITY ANNOTATIONS
#
#    Section 1 says what a Jev question IS. This section says what the Jev
#    backend CAN DO. The two are independent claims and are carried by
#    different mechanisms on purpose.
#
#    Jev's primitives are dual-natured: intensionally each is a question
#    type, which is why rdfs:subClassOf is correct above; extensionally
#    each names a capability of the model, which is what a binding
#    validator or a UI needs when it offers the user the backends able to
#    run a given decision. dm:implementsDecisionType is an annotation
#    property, so these assertions on classes stay within OWL 2 DL, need
#    no punning, and entail nothing about any instance.
# =====================================================================

jev:Choice dm:implementsDecisionType dm:CategoricalDecision .
jev:Score  dm:implementsDecisionType dm:OrdinalDecision .
jev:Noul   dm:implementsDecisionType dm:BinaryDecision .

# =====================================================================
# 5. CANONICAL INDIVIDUALS
#
#    Jev described in the generic execution vocabulary. These are not
#    examples: they are the stable identifiers a binding should cite.
# =====================================================================

jevx:TypeSafeAI
    a dm:Provider ;
    rdfs:label "TypeSafe AI"@en ;
    rdfs:comment "The provider of the Jev System One model."@en ;
    rdfs:seeAlso <https://typesafe.ai/> .

jevx:SystemOneAPI
    a dm:Executor ;
    rdfs:label "TypeSafe System One API"@en ;
    rdfs:comment "The hosted execution backend that answers System One evaluations at POST https://api.typesafe.ai/v1/systemone."@en ;
    dm:provider jevx:TypeSafeAI ;
    dm:implementsDecisionType dm:CategoricalDecision, dm:OrdinalDecision, dm:BinaryDecision ;
    rdfs:seeAlso <https://docs.typesafe.ai/primitives> .
