@prefix : <https://ontology.inferal.com/modules/competency-question/> .
@prefix dcat: <http://www.w3.org/ns/dcat#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix ex: <https://example.com/competency-question/> .
@prefix mod: <https://w3id.org/mod#> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

# People and software can be stakeholders. This example names the maintainer
# whose release decision motivates the question; it does not claim authorship.
ex:maintainer
    a prov:Agent ;
    dcterms:title "Ontology maintainer" .

# A use case records why answering the CQ matters to a decision.
ex:catalog-use-case
    a :UseCase ;
    :useCaseText "An ontology maintainer decides whether a catalog release preserves its documented discovery contract."@en .

# A requirement states the target capability. It is intentionally separate from
# the interrogative wording used to evaluate that capability.
ex:catalog-requirement
    a :OntologyRequirement ;
    :requirementText "The catalog must expose every public ontology module as a discoverable semantic artifact."@en .

# Formulations are resources so their language and provenance can be recorded
# without making the literal itself the identity of the competency question.
ex:catalog-cq-formulation
    a :QuestionFormulation ;
    :formulationText "Which public ontology modules fail to satisfy catalog discovery?"@en ;
    prov:wasAttributedTo ex:maintainer .

# A template keeps one convenient human-readable rendering, but its structured
# elements and parameters are authoritative. Consumers do not parse brackets.
ex:which-resources-template
    a :QuestionTemplate ;
    :templateText "Which [resource kind] fail to satisfy [condition]?"@en ;
    :hasTemplateParameter
        ex:resource-kind-parameter ,
        ex:condition-parameter ;
    :hasTemplateElement
        ex:which-resources-element-0 ,
        ex:which-resources-element-1 ,
        ex:which-resources-element-2 ,
        ex:which-resources-element-3 ,
        ex:which-resources-element-4 .

# Parameters are the stable logical inputs. Their names and roles can change
# without changing the identity used by slot occurrences and bindings.
ex:resource-kind-parameter
    a :TemplateParameter ;
    :parameterName "resource-kind" ;
    :parameterRole ex:resource-phrase-role .

ex:condition-parameter
    a :TemplateParameter ;
    :parameterName "condition" ;
    :parameterRole ex:condition-phrase-role .

# Each named element is one occurrence. Its index, rather than Turtle statement
# order, determines its position in the template.
ex:which-resources-element-0
    a :TemplateTextSegment ;
    :elementIndex "0"^^xsd:nonNegativeInteger ;
    :segmentText "Which "@en .

# A slot is one ordered occurrence and points to its logical parameter. The
# parameter role does not claim a mapping to an ontology class or query variable.
ex:which-resources-element-1
    a :TemplateSlot ;
    :elementIndex "1"^^xsd:nonNegativeInteger ;
    :usesParameter ex:resource-kind-parameter .

ex:which-resources-element-2
    a :TemplateTextSegment ;
    :elementIndex "2"^^xsd:nonNegativeInteger ;
    :segmentText " fail to satisfy "@en .

ex:which-resources-element-3
    a :TemplateSlot ;
    :elementIndex "3"^^xsd:nonNegativeInteger ;
    :usesParameter ex:condition-parameter .

# Punctuation belongs to a text segment when it is fixed by the template.
ex:which-resources-element-4
    a :TemplateTextSegment ;
    :elementIndex "4"^^xsd:nonNegativeInteger ;
    :segmentText "?"@en .

ex:resource-phrase-role
    rdfs:label "resource phrase role" ;
    rdfs:comment "Example extension value for a slot filled by a resource-denoting natural-language phrase." .

ex:condition-phrase-role
    rdfs:label "condition phrase role" ;
    rdfs:comment "Example extension value for a slot filled by a natural-language condition phrase." .

# The qualified instantiation names the exact formulation and binds each
# parameter once. bindingText supplies the language-specific surface wording;
# the bound RDF value remains separately available to semantic consumers.
ex:catalog-template-instantiation
    a :TemplateInstantiation ;
    :usesTemplate ex:which-resources-template ;
    :realizesFormulation ex:catalog-cq-formulation ;
    :hasTemplateBinding
        ex:catalog-resource-kind-binding ,
        ex:catalog-condition-binding ;
    prov:wasAttributedTo ex:maintainer .

ex:catalog-resource-kind-binding
    a :TemplateBinding ;
    :bindsParameter ex:resource-kind-parameter ;
    :boundResource mod:SemanticArtefact ;
    :bindingText "public ontology modules"@en .

ex:catalog-condition-binding
    a :TemplateBinding ;
    :bindsParameter ex:condition-parameter ;
    :boundLiteral "catalog discovery"@en ;
    :bindingText "catalog discovery"@en .

# This is the answer expected before execution, not a result observed from a run.
ex:catalog-cq-answer
    a :ExpectedAnswer ;
    :answerText "No public ontology modules are missing."@en .

# A fixture is named execution input. Its existence does not prove query success.
ex:catalog-fixture
    a :TestFixture ;
    dcterms:format "text/turtle" ;
    dcat:downloadURL <https://example.com/fixtures/catalog.ttl> .

# Query text stays attached to an executable artifact and is interpreted only
# under the declared query language. It is not ontology or SHACL semantics.
ex:catalog-gap-query
    a :FormalQuery ;
    :queryLanguage <https://www.w3.org/TR/sparql11-query/> ;
    :queryText "SELECT ?module WHERE { ?module a <https://w3id.org/mod#SemanticArtefact> . FILTER NOT EXISTS { <https://ontology.inferal.com/src/> <http://purl.org/dc/terms/hasPart> ?module } }" ;
    :usesFixture ex:catalog-fixture ;
    dcat:downloadURL <https://example.com/queries/catalog-gaps.rq> .

# The CQ is the durable identity joining independently maintained concerns.
# Adding a translation or alternate query would not require changing this IRI.
ex:catalog-cq
    a :CompetencyQuestion ;
    :hasFormulation ex:catalog-cq-formulation ;
    :addressesRequirement ex:catalog-requirement ;
    :supportsUseCase ex:catalog-use-case ;
    :hasStakeholder ex:maintainer ;
    :questionKind :ValidationQuestion ;
    :questionPurpose :RegressionPurpose ;
    :targetsArtifact ex:catalog ;
    :targetsVersion ex:catalog-version ;
    :hasAnswerExpectation ex:catalog-cq-answer ;
    :hasFormalQuery ex:catalog-gap-query ;
    :hasTemplateInstantiation ex:catalog-template-instantiation ;
    :lifecycleState :AcceptedState ;
    :reviewState :ApprovedState .

# Artifact and version are distinct resources so executions can state which
# version they actually used and stale evidence can be detected later.
ex:catalog
    a mod:SemanticArtefact ;
    dcterms:title "Example ontology catalog" .

ex:catalog-version
    a mod:SemanticArtefact ;
    dcterms:isVersionOf ex:catalog ;
    dcterms:hasVersion "2026-07-29" .

# A query execution is a time-bounded PROV activity, not a reusable query and
# not its generated result. prov:used records the evaluated target version.
ex:catalog-query-run
    a :QueryExecution ;
    :executionOf ex:catalog-gap-query ;
    :evaluatesQuestion ex:catalog-cq ;
    :usesFixture ex:catalog-fixture ;
    :hasExecutionResult ex:catalog-query-result ;
    prov:used ex:catalog-version ;
    prov:endedAtTime "2026-07-29T12:00:00Z"^^xsd:dateTime .

# Zero is an explicit machine observation. If resultCardinality were absent,
# the result would not silently mean zero.
ex:catalog-query-result
    a :ExecutionResult ;
    :executionStatus :PassedStatus ;
    :resultCardinality "0"^^xsd:nonNegativeInteger ;
    :resultMessage "The example execution returned zero missing modules." ;
    prov:wasGeneratedBy ex:catalog-query-run .

# Coverage is qualified so its question, resource, and degree remain explicit.
# This assertion says nothing about the coverage of unmentioned resources.
ex:catalog-cq-coverage
    a :CoverageAssertion ;
    :coverageQuestion ex:catalog-cq ;
    :coveredResource ex:catalog-requirement ;
    :coverageStatus :CoveredStatus .

# A question set provides collection-level purpose and stakeholder context.
# One listed member does not entail that this set is exhaustive.
ex:catalog-regression-set
    a :QuestionSet ;
    :containsQuestion ex:catalog-cq ;
    :questionPurpose :RegressionPurpose ;
    :hasStakeholder ex:maintainer .
