
Bdi Mental States
- 96 installs
- 941 repo stars
- Updated August 5, 2026
- guanyang/antigravity-skills
Model agent beliefs, desires, and intentions from RDF context using a formal BDI ontology for deliberative, explainable reasoning.
About
Transforms external RDF context into agent mental states (beliefs, desires, intentions) using formal BDI ontology patterns and a triples-to-beliefs-to-triples pipeline. A developer uses it when building cognitive multi-agent systems that need traceable, explainable reasoning.
- Wires beliefs/desires/intentions into cognitive chains with bidirectional properties and Turtle/SPARQL examples
- Includes T2B2T pipeline, temporal validity intervals, and Logic Augmented Generation to constrain LLM output
Bdi Mental States by the numbers
- 96 all-time installs (skills.sh)
- Ranked #4,561 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/guanyang/antigravity-skills --skill bdi-mental-statesAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 96 |
|---|---|
| repo stars | ★ 941 |
| Last updated | August 5, 2026 |
| Repository | guanyang/antigravity-skills ↗ |
What it does
Model agent beliefs, desires, and intentions from RDF context using a formal BDI ontology for deliberative, explainable reasoning.
Files
BDI Mental State Modeling
Transform external RDF context into agent mental states (beliefs, desires, intentions) using formal BDI ontology patterns. This skill enables agents to reason about context through cognitive architecture, supporting deliberative reasoning, explainability, and semantic interoperability within multi-agent systems.
When to Activate
Activate this skill when:
- Processing external RDF context into agent beliefs about world states
- Modeling rational agency with perception, deliberation, and action cycles
- Enabling explainability through traceable reasoning chains
- Implementing BDI frameworks (SEMAS, JADE, JADEX)
- Augmenting LLMs with formal cognitive structures (Logic Augmented Generation)
- Coordinating mental states across multi-agent platforms
- Tracking temporal evolution of beliefs, desires, and intentions
- Linking motivational states to action plans
Core Concepts
Mental Reality Architecture
Separate mental states into two ontological categories because BDI reasoning requires distinguishing what persists from what happens:
Mental States (Endurants) -- model these as persistent cognitive attributes that hold over time intervals:
Belief: Represent what the agent holds true about the world. Ground every belief in a world state reference.Desire: Represent what the agent wishes to bring about. Link each desire back to the beliefs that motivate it.Intention: Represent what the agent commits to achieving. An intention must fulfil a desire and specify a plan.
Mental Processes (Perdurants) -- model these as events that create or modify mental states, because tracking causal transitions enables explainability:
BeliefProcess: Triggers belief formation/update from perception. Always connect to a generating world state.DesireProcess: Generates desires from existing beliefs. Preserves the motivational chain.IntentionProcess: Commits to selected desires as actionable intentions.
Cognitive Chain Pattern
Wire beliefs, desires, and intentions into directed chains using bidirectional properties (motivates/isMotivatedBy, fulfils/isFulfilledBy) because this enables both forward reasoning (what should the agent do?) and backward tracing (why did the agent act?):
:Belief_store_open a bdi:Belief ;
rdfs:comment "Store is open" ;
bdi:motivates :Desire_buy_groceries .
:Desire_buy_groceries a bdi:Desire ;
rdfs:comment "I desire to buy groceries" ;
bdi:isMotivatedBy :Belief_store_open .
:Intention_go_shopping a bdi:Intention ;
rdfs:comment "I will buy groceries" ;
bdi:fulfils :Desire_buy_groceries ;
bdi:isSupportedBy :Belief_store_open ;
bdi:specifies :Plan_shopping .World State Grounding
Always ground mental states in world state references rather than free-text descriptions, because ungrounded beliefs break semantic querying and cross-agent interoperability:
:Agent_A a bdi:Agent ;
bdi:perceives :WorldState_WS1 ;
bdi:hasMentalState :Belief_B1 .
:WorldState_WS1 a bdi:WorldState ;
rdfs:comment "Meeting scheduled at 10am in Room 5" ;
bdi:atTime :TimeInstant_10am .
:Belief_B1 a bdi:Belief ;
bdi:refersTo :WorldState_WS1 .Goal-Directed Planning
Connect intentions to plans via bdi:specifies, and decompose plans into ordered task sequences using bdi:precedes, because this separation allows plan reuse across different intentions while keeping execution order explicit:
:Intention_I1 bdi:specifies :Plan_P1 .
:Plan_P1 a bdi:Plan ;
bdi:addresses :Goal_G1 ;
bdi:beginsWith :Task_T1 ;
bdi:endsWith :Task_T3 .
:Task_T1 bdi:precedes :Task_T2 .
:Task_T2 bdi:precedes :Task_T3 .T2B2T Paradigm
Implement Triples-to-Beliefs-to-Triples as a bidirectional pipeline because agents must both consume external RDF context and produce new RDF assertions. Structure every T2B2T implementation in two explicit phases:
Phase 1: Triples-to-Beliefs -- Translate incoming RDF triples into belief instances. Use bdi:triggers to connect the external world state to a BeliefProcess, and bdi:generates to produce the resulting belief. This preserves provenance from source data through to internal cognition:
:WorldState_notification a bdi:WorldState ;
rdfs:comment "Push notification: Payment request $250" ;
bdi:triggers :BeliefProcess_BP1 .
:BeliefProcess_BP1 a bdi:BeliefProcess ;
bdi:generates :Belief_payment_request .Phase 2: Beliefs-to-Triples -- After BDI deliberation selects an intention and executes a plan, project the results back into RDF using bdi:bringsAbout. This closes the loop so downstream systems can consume agent outputs as standard linked data:
:Intention_pay a bdi:Intention ;
bdi:specifies :Plan_payment .
:PlanExecution_PE1 a bdi:PlanExecution ;
bdi:satisfies :Plan_payment ;
bdi:bringsAbout :WorldState_payment_complete .Notation Selection by Level
Choose notation based on the C4 abstraction level being modeled, because mixing notations at the wrong level obscures rather than clarifies the cognitive architecture:
| C4 Level | Notation | Mental State Representation |
|---|---|---|
| L1 Context | ArchiMate | Agent boundaries, external perception sources |
| L2 Container | ArchiMate | BDI reasoning engine, belief store, plan executor |
| L3 Component | UML | Mental state managers, process handlers |
| L4 Code | UML/RDF | Belief/Desire/Intention classes, ontology instances |
Justification and Explainability
Attach bdi:Justification instances to every mental entity using bdi:isJustifiedBy, because unjustified mental states make agent reasoning opaque and untraceable. Each justification should capture the evidence or rule that produced the mental state:
:Belief_B1 a bdi:Belief ;
bdi:isJustifiedBy :Justification_J1 .
:Justification_J1 a bdi:Justification ;
rdfs:comment "Official announcement received via email" .
:Intention_I1 a bdi:Intention ;
bdi:isJustifiedBy :Justification_J2 .
:Justification_J2 a bdi:Justification ;
rdfs:comment "Location precondition satisfied" .Temporal Dimensions
Assign validity intervals to every mental state using bdi:hasValidity with TimeInterval instances, because beliefs without temporal bounds cannot be garbage-collected or conflict-checked during diachronic reasoning:
:Belief_B1 a bdi:Belief ;
bdi:hasValidity :TimeInterval_TI1 .
:TimeInterval_TI1 a bdi:TimeInterval ;
bdi:hasStartTime :TimeInstant_9am ;
bdi:hasEndTime :TimeInstant_11am .Query mental states active at a specific moment using SPARQL temporal filters. Use this pattern to resolve conflicts when multiple beliefs about the same world state overlap in time:
SELECT ?mentalState WHERE {
?mentalState bdi:hasValidity ?interval .
?interval bdi:hasStartTime ?start ;
bdi:hasEndTime ?end .
FILTER(?start <= "2025-01-04T10:00:00"^^xsd:dateTime &&
?end >= "2025-01-04T10:00:00"^^xsd:dateTime)
}Compositional Mental Entities
Decompose complex beliefs into constituent parts using bdi:hasPart relations, because monolithic beliefs force full replacement on partial updates. Structure composite beliefs so that each sub-belief can be independently updated, queried, or invalidated:
:Belief_meeting a bdi:Belief ;
rdfs:comment "Meeting at 10am in Room 5" ;
bdi:hasPart :Belief_meeting_time , :Belief_meeting_location .
# Update only location component without touching time
:BeliefProcess_update a bdi:BeliefProcess ;
bdi:modifies :Belief_meeting_location .Integration Patterns
Logic Augmented Generation (LAG)
Use LAG to constrain LLM outputs with ontological structure, because unconstrained generation produces triples that violate BDI class restrictions. Serialize the ontology into the prompt context, then validate generated triples against it before accepting them:
def augment_llm_with_bdi_ontology(prompt, ontology_graph):
ontology_context = serialize_ontology(ontology_graph, format='turtle')
augmented_prompt = f"{ontology_context}\n\n{prompt}"
response = llm.generate(augmented_prompt)
triples = extract_rdf_triples(response)
is_consistent = validate_triples(triples, ontology_graph)
return triples if is_consistent else retry_with_feedback()SEMAS Rule Translation
Translate BDI ontology patterns into executable production rules when deploying to rule-based agent platforms. Map each cognitive chain link (belief-to-desire, desire-to-intention) to a HEAD/CONDITIONALS/TAIL rule, because this preserves the deliberative semantics while enabling runtime execution:
% Belief triggers desire formation
[HEAD: belief(agent_a, store_open)] /
[CONDITIONALS: time(weekday_afternoon)] »
[TAIL: generate_desire(agent_a, buy_groceries)].
% Desire triggers intention commitment
[HEAD: desire(agent_a, buy_groceries)] /
[CONDITIONALS: belief(agent_a, has_shopping_list)] »
[TAIL: commit_intention(agent_a, buy_groceries)].Guidelines
1. Model world states as configurations independent of agent perspectives, providing referential substrate for mental states.
2. Distinguish endurants (persistent mental states) from perdurants (temporal mental processes), aligning with DOLCE ontology.
3. Treat goals as descriptions rather than mental states, maintaining separation between cognitive and planning layers.
4. Use hasPart relations for meronymic structures enabling selective belief updates.
5. Associate every mental entity with temporal constructs via atTime or hasValidity.
6. Use bidirectional property pairs (motivates/isMotivatedBy, generates/isGeneratedBy) for flexible querying.
7. Link mental entities to Justification instances for explainability and trust.
8. Implement T2B2T through: (1) translate RDF to beliefs, (2) execute BDI reasoning, (3) project mental states back to RDF.
9. Define existential restrictions on mental processes (e.g., BeliefProcess ⊑ ∃generates.Belief).
10. Reuse established ODPs (EventCore, Situation, TimeIndexedSituation, BasicPlan, Provenance) for interoperability.
Competency Questions
Validate implementation against these SPARQL queries:
# CQ1: What beliefs motivated formation of a given desire?
SELECT ?belief WHERE {
:Desire_D1 bdi:isMotivatedBy ?belief .
}
# CQ2: Which desire does a particular intention fulfill?
SELECT ?desire WHERE {
:Intention_I1 bdi:fulfils ?desire .
}
# CQ3: Which mental process generated a belief?
SELECT ?process WHERE {
?process bdi:generates :Belief_B1 .
}
# CQ4: What is the ordered sequence of tasks in a plan?
SELECT ?task ?nextTask WHERE {
:Plan_P1 bdi:hasComponent ?task .
OPTIONAL { ?task bdi:precedes ?nextTask }
} ORDER BY ?taskGotchas
1. Conflating mental states with world states: Mental states reference world states via bdi:refersTo, they are not world states themselves. Mixing them collapses the perception-cognition boundary and breaks SPARQL queries that filter by type.
2. Missing temporal bounds: Every mental state needs validity intervals for diachronic reasoning. Without them, stale beliefs persist indefinitely and conflict detection becomes impossible.
3. Flat belief structures: Use compositional modeling with hasPart for complex beliefs. Monolithic beliefs force full replacement when only one attribute changes.
4. Implicit justifications: Always link mental entities to explicit Justification instances. Unjustified mental states cannot be audited or traced.
5. Direct intention-to-action mapping: Intentions specify plans which contain tasks; actions execute tasks. Skipping the plan layer removes the ability to reuse, reorder, or share execution strategies.
6. Ontology over-complexity: Start with 5-10 core classes and properties (Belief, Desire, Intention, WorldState, Plan, plus key relations). Expanding the ontology prematurely inflates prompt context and slows SPARQL queries without improving reasoning quality.
7. Reasoning cost explosion: Keep belief chains to 3 levels or fewer (belief -> desire -> intention). Deeper chains become prohibitively expensive for LLM inference and rarely improve decision quality over shallower alternatives.
Integration
- RDF Processing: Apply after parsing external RDF context to construct cognitive representations
- Semantic Reasoning: Combine with ontology reasoning to infer implicit mental state relationships
- Multi-Agent Communication: Integrate with FIPA ACL for cross-platform belief sharing
- Temporal Context: Coordinate with temporal reasoning for mental state evolution
- Explainable AI: Feed into explanation systems tracing perception through deliberation to action
- Neuro-Symbolic AI: Apply in LAG pipelines to constrain LLM outputs with cognitive structures
References
Internal references:
- BDI Ontology Core - Read when: implementing BDI class hierarchies or defining ontology properties from scratch
- RDF Examples - Read when: writing Turtle serializations of mental states or debugging triple structure
- SPARQL Competency Queries - Read when: validating an implementation against competency questions or building custom queries
- Framework Integration - Read when: deploying BDI models to SEMAS, JADE, or LAG pipelines
Primary sources:
- Zuppiroli et al. "The Belief-Desire-Intention Ontology" (2025) — Read when: implementing formal BDI class hierarchies or validating ontology alignment
- Rao & Georgeff "BDI agents: From theory to practice" (1995) — Read when: understanding the theoretical foundations of practical reasoning agents
- Bratman "Intention, plans, and practical reason" (1987) — Read when: grounding implementation decisions in the philosophical basis of intentionality
---
Skill Metadata
Created: 2026-01-07 Last Updated: 2026-03-17 Author: Agent Skills for Context Engineering Contributors Version: 2.0.0
BDI Ontology Core Patterns
Core ontology design patterns for Belief-Desire-Intention mental state modeling.
Class Hierarchy
Mental Entities (Endurants)
bdi:MentalEntity
├── bdi:Belief # Informational dimension
├── bdi:Desire # Motivational dimension
├── bdi:Intention # Deliberative dimension
├── bdi:Goal # Description of desired end state
└── bdi:Plan # Structured action sequenceMental Processes (Perdurants)
bdi:MentalProcess
├── bdi:BeliefProcess # Forms/updates beliefs from perception
├── bdi:DesireProcess # Generates desires from beliefs
├── bdi:IntentionProcess # Commits to desires as intentions
├── bdi:Planning # Transforms intentions into plans
└── bdi:PlanExecution # Executes plan actionsSupporting Entities
bdi:WorldState # Configuration of environment
bdi:Justification # Evidential basis for mental states
bdi:Task # Atomic unit of planned action
bdi:Action # Execution of a task
bdi:TimeInterval # Temporal validity bounds
bdi:TimeInstant # Point in time referenceObject Properties
Motivational Relations
| Property | Domain | Range | Description |
|---|---|---|---|
motivates | Belief | Desire | Belief provides reason for desire |
isMotivatedBy | Desire | Belief | Inverse of motivates |
fulfils | Intention | Desire | Intention commits to achieving desire |
isFulfilledBy | Desire | Intention | Inverse of fulfils |
isSupportedBy | Intention | Belief | Beliefs supporting intention viability |
Generative Relations
| Property | Domain | Range | Description |
|---|---|---|---|
generates | MentalProcess | MentalEntity | Process creates mental state |
isGeneratedBy | MentalEntity | MentalProcess | Inverse of generates |
modifies | MentalProcess | MentalEntity | Process updates existing state |
suppresses | MentalProcess | MentalEntity | Process deactivates state |
isTriggeredBy | MentalProcess | MentalEntity | State initiates process |
Referential Relations
| Property | Domain | Range | Description |
|---|---|---|---|
refersTo | MentalEntity | WorldState | Mental state about world |
perceives | Agent | WorldState | Agent observes world |
bringsAbout | Action | WorldState | Action causes world change |
reasonsUpon | MentalProcess | MentalEntity | Input to reasoning |
Structural Relations
| Property | Domain | Range | Description |
|---|---|---|---|
hasPart | MentalEntity | MentalEntity | Meronymic composition |
specifies | Intention | Plan | Intention defines plan |
addresses | Plan | Goal | Plan achieves goal |
hasComponent | Plan | Task | Plan contains tasks |
precedes | Task | Task | Task ordering |
Temporal Relations
| Property | Domain | Range | Description |
|---|---|---|---|
atTime | Entity | TimeInstant | Point occurrence |
hasValidity | MentalEntity | TimeInterval | Persistence bounds |
hasStartTime | TimeInterval | TimeInstant | Interval start |
hasEndTime | TimeInterval | TimeInstant | Interval end |
Justification Relations
| Property | Domain | Range | Description |
|---|---|---|---|
isJustifiedBy | MentalEntity | Justification | Evidential support |
justifies | Justification | MentalEntity | Inverse relation |
Ontological Restrictions
Belief Restrictions
bdi:Belief rdfs:subClassOf [
a owl:Restriction ;
owl:onProperty bdi:refersTo ;
owl:someValuesFrom bdi:WorldState
] .
bdi:Belief rdfs:subClassOf [
a owl:Restriction ;
owl:onProperty bdi:hasValidity ;
owl:maxCardinality 1
] .Desire Restrictions
bdi:Desire rdfs:subClassOf [
a owl:Restriction ;
owl:onProperty bdi:isMotivatedBy ;
owl:someValuesFrom bdi:Belief
] .Intention Restrictions
bdi:Intention rdfs:subClassOf [
a owl:Restriction ;
owl:onProperty bdi:fulfils ;
owl:cardinality 1
] .
bdi:Intention rdfs:subClassOf [
a owl:Restriction ;
owl:onProperty bdi:isSupportedBy ;
owl:someValuesFrom bdi:Belief
] .Mental Process Restrictions
bdi:BeliefProcess rdfs:subClassOf [
a owl:Restriction ;
owl:onProperty bdi:generates ;
owl:allValuesFrom bdi:Belief
] .
bdi:DesireProcess rdfs:subClassOf [
a owl:Restriction ;
owl:onProperty bdi:generates ;
owl:allValuesFrom bdi:Desire
] .
bdi:IntentionProcess rdfs:subClassOf [
a owl:Restriction ;
owl:onProperty bdi:generates ;
owl:allValuesFrom bdi:Intention
] .DOLCE Alignment
The BDI ontology aligns with DOLCE Ultra Lite (DUL) foundational ontology:
| BDI Class | DUL Superclass | Rationale |
|---|---|---|
Agent | dul:Agent | Intentional entity capable of action |
Belief | dul:InformationObject | Information-bearing entity |
Desire | dul:Description | Describes desired state |
Intention | dul:Description | Describes committed course |
Goal | dul:Goal | Desired end state description |
Plan | dul:Plan | Organized action sequence |
WorldState | dul:Situation | Configuration of entities |
MentalProcess | dul:Event | Temporally extended occurrence |
Task | dul:Task | Unit of planned work |
Action | dul:Action | Performed task instance |
Reused Ontology Design Patterns
EventCore Pattern
Used for mental processes with temporal aspects and participant roles.
Situation Pattern
Used for world state configurations that mental states reference.
TimeIndexedSituation Pattern
Used for associating mental states with validity intervals.
BasicPlan Pattern
Used for goal-plan-task structures linking intentions to actions.
Provenance Pattern
Used for justification tracking and evidential chains.
Namespace Declarations
@prefix bdi: <https://w3id.org/fossr/ontology/bdi/> .
@prefix dul: <http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .BDI Framework Integration Patterns
Integration patterns for connecting BDI ontology with executable agent frameworks.
SEMAS Rule Translation
Map BDI ontology constructs to SEMAS production rules.
Ontology-to-Rule Mapping
| BDI Construct | SEMAS Element | Example |
|---|---|---|
| Belief | HEAD fact | belief(agent_a, store_open) |
| Supporting beliefs | CONDITIONALS | [CONDITIONALS: time(weekday)] |
| Desire generation | TAIL action | generate_desire(agent, goal) |
| Intention commitment | TAIL action | commit_intention(agent, goal) |
| Plan specification | TAIL action | create_plan(agent, plan_id) |
Rule Templates
Belief triggers desire formation:
[HEAD: belief(Agent, Fact)] /
[CONDITIONALS: context_condition(Agent, Context)] »
[TAIL: generate_desire(Agent, DesiredState)].Desire triggers intention commitment:
[HEAD: desire(Agent, Goal)] /
[CONDITIONALS: belief(Agent, SupportingFact1),
belief(Agent, SupportingFact2)] »
[TAIL: commit_intention(Agent, Goal)].Intention triggers planning:
[HEAD: intention(Agent, Goal)] /
[CONDITIONALS: goal(GoalSpec)] »
[TAIL: create_plan(Agent, PlanId)].Plan triggers execution:
[HEAD: plan(Agent, PlanId)] /
[CONDITIONALS: ready_to_execute(Agent)] »
[TAIL: execute_plan(Agent, PlanId)].Complete SEMAS Example
% ============================================================
% GROCERY SHOPPING SCENARIO
% ============================================================
% Phase 1: Belief formation from world state
[HEAD: perceive(agent_a, store_open)] /
[CONDITIONALS: time(weekday_afternoon)] »
[TAIL: add_belief(agent_a, store_open)].
% Phase 2: Desire generation from belief
[HEAD: belief(agent_a, store_open)] /
[CONDITIONALS: belief(agent_a, needs_groceries)] »
[TAIL: generate_desire(agent_a, buy_groceries)].
% Phase 3: Intention commitment from desire
[HEAD: desire(agent_a, buy_groceries)] /
[CONDITIONALS: belief(agent_a, has_shopping_list),
belief(agent_a, store_open),
belief(agent_a, has_transportation)] »
[TAIL: commit_intention(agent_a, buy_groceries)].
% Phase 4: Plan creation from intention
[HEAD: intention(agent_a, buy_groceries)] /
[CONDITIONALS: goal(complete_shopping)] »
[TAIL: create_plan(agent_a, shopping_plan)].
% Phase 5: Plan execution
[HEAD: plan(agent_a, shopping_plan)] /
[CONDITIONALS: preconditions_met(shopping_plan)] »
[TAIL: execute_task(agent_a, drive_to_store),
execute_task(agent_a, select_items),
execute_task(agent_a, checkout),
execute_task(agent_a, return_home)].
% Phase 6: World state update
[HEAD: task_complete(agent_a, checkout)] /
[CONDITIONALS: items_purchased(agent_a)] »
[TAIL: update_world_state(has_groceries),
remove_desire(agent_a, buy_groceries),
remove_intention(agent_a, buy_groceries)].Python Translation Layer
from rdflib import Graph, Namespace, RDF
BDI = Namespace("https://w3id.org/fossr/ontology/bdi/")
def ontology_to_semas_rules(bdi_graph: Graph) -> list[str]:
"""
Translate BDI ontology instances to SEMAS production rules.
"""
rules = []
# Extract belief-desire-intention chains
for intention in bdi_graph.subjects(RDF.type, BDI.Intention):
# Get supporting beliefs
supporting_beliefs = list(bdi_graph.objects(intention, BDI.isSupportedBy))
# Get fulfilled desire
fulfilled_desires = list(bdi_graph.objects(intention, BDI.fulfils))
# Get specified plan
specified_plans = list(bdi_graph.objects(intention, BDI.specifies))
if fulfilled_desires and supporting_beliefs:
desire = fulfilled_desires[0]
beliefs_str = ", ".join([format_belief(b, bdi_graph) for b in supporting_beliefs])
rule = (
f"[HEAD: {format_desire(desire, bdi_graph)}] / "
f"[CONDITIONALS: {beliefs_str}] » "
f"[TAIL: commit_intention({format_intention(intention, bdi_graph)})]"
)
rules.append(rule)
if specified_plans:
plan = specified_plans[0]
rule = (
f"[HEAD: {format_intention(intention, bdi_graph)}] / "
f"[CONDITIONALS: ready_to_plan] » "
f"[TAIL: create_plan({format_plan(plan, bdi_graph)})]"
)
rules.append(rule)
return rules
def format_belief(belief_uri, graph):
label = graph.value(belief_uri, RDFS.label)
return f"belief({label or belief_uri.split('/')[-1]})"
def format_desire(desire_uri, graph):
label = graph.value(desire_uri, RDFS.label)
return f"desire({label or desire_uri.split('/')[-1]})"
def format_intention(intention_uri, graph):
label = graph.value(intention_uri, RDFS.label)
return f"intention({label or intention_uri.split('/')[-1]})"
def format_plan(plan_uri, graph):
label = graph.value(plan_uri, RDFS.label)
return f"plan({label or plan_uri.split('/')[-1]})"Logic Augmented Generation (LAG)
Augment LLM outputs with BDI ontological constraints.
LAG Pipeline Architecture
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ User Query │────▶│ Ontology │────▶│ Augmented │
│ │ │ Injection │ │ Prompt │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Validated │◀────│ Ontology │◀────│ LLM Response │
│ RDF Triples │ │ Validation │ │ (Triples) │
└─────────────────┘ └─────────────────┘ └─────────────────┘LAG Implementation
from rdflib import Graph, Namespace
from rdflib.plugins.parsers.notation3 import BadSyntax
BDI = Namespace("https://w3id.org/fossr/ontology/bdi/")
class BDILogicAugmentedGenerator:
def __init__(self, ontology_path: str, llm_client):
self.ontology = Graph()
self.ontology.parse(ontology_path, format='turtle')
self.llm = llm_client
def generate_mental_states(self, context: str) -> Graph:
"""
Generate BDI mental states from context using LAG.
"""
# Phase 1: Inject ontology into prompt
ontology_turtle = self.ontology.serialize(format='turtle')
augmented_prompt = self._build_augmented_prompt(context, ontology_turtle)
# Phase 2: Generate with LLM
response = self.llm.generate(augmented_prompt)
# Phase 3: Extract and validate triples
triples = self._extract_triples(response)
validated = self._validate_against_ontology(triples)
if not validated['is_consistent']:
# Retry with feedback
return self._retry_with_feedback(context, validated['errors'])
return validated['graph']
def _build_augmented_prompt(self, context: str, ontology: str) -> str:
return f"""
You are a BDI mental state modeler. Given the following context, generate
RDF triples representing the agent's beliefs, desires, and intentions.
## BDI Ontology (use these classes and properties):
{ontology}
## Context to Model:
{context}
## Instructions:
1. Identify world states from the context
2. Generate beliefs that refer to those world states
3. Generate desires motivated by those beliefs
4. Generate intentions that fulfill desires and are supported by beliefs
5. Include justifications for each mental state
6. Include temporal validity intervals
Output valid Turtle RDF triples only.
"""
def _extract_triples(self, response: str) -> str:
"""Extract Turtle content from LLM response."""
# Find turtle block in response
if "```turtle" in response:
start = response.find("```turtle") + 9
end = response.find("```", start)
return response[start:end].strip()
return response
def _validate_against_ontology(self, triples: str) -> dict:
"""Validate generated triples against BDI ontology."""
result = {'is_consistent': True, 'errors': [], 'graph': None}
try:
generated = Graph()
generated.parse(data=triples, format='turtle')
result['graph'] = generated
# Validate constraints
errors = []
# Check: Every intention must fulfill a desire
for intention in generated.subjects(RDF.type, BDI.Intention):
if not list(generated.objects(intention, BDI.fulfils)):
errors.append(f"Intention {intention} does not fulfill any desire")
# Check: Every belief should reference a world state
for belief in generated.subjects(RDF.type, BDI.Belief):
if not list(generated.objects(belief, BDI.refersTo)):
errors.append(f"Belief {belief} does not reference a world state")
# Check: Desires should be motivated by beliefs
for desire in generated.subjects(RDF.type, BDI.Desire):
if not list(generated.objects(desire, BDI.isMotivatedBy)):
errors.append(f"Desire {desire} has no motivating belief")
if errors:
result['is_consistent'] = False
result['errors'] = errors
except BadSyntax as e:
result['is_consistent'] = False
result['errors'] = [f"Invalid Turtle syntax: {e}"]
return result
def _retry_with_feedback(self, context: str, errors: list) -> Graph:
"""Retry generation with error feedback."""
feedback_prompt = f"""
Previous generation had errors:
{chr(10).join(errors)}
Please regenerate the mental states fixing these issues.
Context: {context}
"""
response = self.llm.generate(feedback_prompt)
triples = self._extract_triples(response)
result = self._validate_against_ontology(triples)
if result['is_consistent']:
return result['graph']
else:
raise ValueError(f"Failed to generate valid mental states: {result['errors']}")Inconsistency Detection Example
def detect_location_inconsistency(graph: Graph) -> list[str]:
"""
Detect inconsistencies where agent cannot be in two places.
"""
inconsistencies = []
# Query for location beliefs
query = """
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?agent ?belief1 ?belief2 ?loc1 ?loc2 WHERE {
?agent bdi:hasBelief ?belief1 , ?belief2 .
?belief1 bdi:refersTo ?ws1 .
?belief2 bdi:refersTo ?ws2 .
?ws1 bdi:hasLocation ?loc1 .
?ws2 bdi:hasLocation ?loc2 .
FILTER(?belief1 != ?belief2 && ?loc1 != ?loc2)
# Check temporal overlap
?belief1 bdi:hasValidity ?interval1 .
?belief2 bdi:hasValidity ?interval2 .
?interval1 bdi:hasStartTime ?start1 ; bdi:hasEndTime ?end1 .
?interval2 bdi:hasStartTime ?start2 ; bdi:hasEndTime ?end2 .
FILTER(?start1 < ?end2 && ?start2 < ?end1)
}
"""
for row in graph.query(query):
inconsistencies.append(
f"Agent {row.agent} has conflicting location beliefs: "
f"{row.loc1} and {row.loc2} at overlapping times"
)
return inconsistenciesJADE/JADEX Integration
Map BDI ontology to JADE/JADEX agent platform structures.
JADE Agent Structure
public class BDIAgent extends Agent {
// Mental state storage (maps to ontology individuals)
private Set<Belief> beliefs = new HashSet<>();
private Set<Desire> desires = new HashSet<>();
private Set<Intention> intentions = new HashSet<>();
// Ontology-backed mental state management
private Graph mentalStateGraph;
public void addBelief(Belief belief) {
beliefs.add(belief);
// Add to RDF graph
Resource beliefResource = mentalStateGraph.createResource(belief.getUri());
beliefResource.addProperty(RDF.type, BDI.Belief);
beliefResource.addProperty(BDI.refersTo, belief.getWorldState().getUri());
beliefResource.addProperty(BDI.hasValidity, createInterval(belief.getValidity()));
// Trigger desire formation
triggerDesireProcess(belief);
}
public void commitIntention(Intention intention) {
intentions.add(intention);
Resource intentionResource = mentalStateGraph.createResource(intention.getUri());
intentionResource.addProperty(RDF.type, BDI.Intention);
intentionResource.addProperty(BDI.fulfils, intention.getDesire().getUri());
for (Belief support : intention.getSupportingBeliefs()) {
intentionResource.addProperty(BDI.isSupportedBy, support.getUri());
}
// Trigger planning
triggerPlanning(intention);
}
// Export mental states as RDF
public String exportMentalStates() {
return mentalStateGraph.serialize(Format.TURTLE);
}
// Import mental states from RDF
public void importMentalStates(String turtle) {
Graph imported = new Graph();
imported.parse(turtle, Format.TURTLE);
// Reconstruct Java objects from RDF
for (Resource belief : imported.listSubjectsWithProperty(RDF.type, BDI.Belief)) {
Belief b = reconstructBelief(belief);
beliefs.add(b);
}
// ... similar for desires and intentions
}
}JADEX Goal Mapping
// Map BDI ontology goals to JADEX goals
@Goal
public class OntologyBackedGoal {
@GoalParameter
protected String goalUri;
@GoalParameter
protected Graph ontologyGraph;
public OntologyBackedGoal(Resource goalResource, Graph graph) {
this.goalUri = goalResource.getURI();
this.ontologyGraph = graph;
}
@GoalTargetCondition
public boolean isAchieved() {
// Query ontology for goal achievement
String query = """
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
ASK {
?execution bdi:addresses <%s> ;
bdi:bringsAbout ?worldState .
}
""".formatted(goalUri);
return ontologyGraph.ask(query);
}
@GoalDropCondition
public boolean shouldDrop() {
// Check if supporting beliefs are invalidated
String query = """
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
ASK {
?intention bdi:specifies ?plan .
?plan bdi:addresses <%s> .
?intention bdi:isSupportedBy ?belief .
?belief bdi:hasValidity ?interval .
?interval bdi:hasEndTime ?end .
FILTER(?end < NOW())
}
""".formatted(goalUri);
return ontologyGraph.ask(query);
}
}RDF Triple Store Integration
Triple Store Configuration
from rdflib import Graph
from rdflib.plugins.stores.sparqlstore import SPARQLUpdateStore
class BDIMentalStateStore:
def __init__(self, endpoint: str):
self.store = SPARQLUpdateStore()
self.store.open((endpoint + "/query", endpoint + "/update"))
self.graph = Graph(store=self.store, identifier="http://example.org/bdi")
def add_belief(self, agent_uri: str, belief_data: dict):
"""Add belief to triple store."""
belief_uri = f"{agent_uri}/belief/{belief_data['id']}"
self.graph.add((URIRef(belief_uri), RDF.type, BDI.Belief))
self.graph.add((URIRef(belief_uri), RDFS.label, Literal(belief_data['label'])))
self.graph.add((URIRef(belief_uri), BDI.refersTo, URIRef(belief_data['world_state'])))
self.graph.add((URIRef(agent_uri), BDI.hasMentalState, URIRef(belief_uri)))
# Add temporal validity
interval_uri = f"{belief_uri}/validity"
self.graph.add((URIRef(belief_uri), BDI.hasValidity, URIRef(interval_uri)))
self.graph.add((URIRef(interval_uri), BDI.hasStartTime,
Literal(belief_data['start_time'], datatype=XSD.dateTime)))
self.graph.add((URIRef(interval_uri), BDI.hasEndTime,
Literal(belief_data['end_time'], datatype=XSD.dateTime)))
def get_active_beliefs(self, agent_uri: str, at_time: datetime) -> list:
"""Query beliefs active at specific time."""
query = """
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?belief ?label WHERE {
<%s> bdi:hasMentalState ?belief .
?belief a bdi:Belief ;
rdfs:label ?label ;
bdi:hasValidity ?interval .
?interval bdi:hasStartTime ?start ;
bdi:hasEndTime ?end .
FILTER(?start <= "%s"^^xsd:dateTime && ?end >= "%s"^^xsd:dateTime)
}
""" % (agent_uri, at_time.isoformat(), at_time.isoformat())
return list(self.graph.query(query))
def get_cognitive_chain(self, intention_uri: str) -> dict:
"""Trace complete cognitive chain for an intention."""
query = """
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?intention ?desire ?belief ?worldState ?plan WHERE {
<%s> a bdi:Intention ;
bdi:fulfils ?desire ;
bdi:isSupportedBy ?belief .
OPTIONAL { <%s> bdi:specifies ?plan }
?desire bdi:isMotivatedBy ?belief .
?belief bdi:refersTo ?worldState .
}
""" % (intention_uri, intention_uri)
results = list(self.graph.query(query))
if results:
row = results[0]
return {
'intention': str(row.intention),
'desire': str(row.desire),
'belief': str(row.belief),
'world_state': str(row.worldState),
'plan': str(row.plan) if row.plan else None
}
return NoneFIPA ACL Integration
Map BDI mental states to FIPA Agent Communication Language.
from fipa_acl import ACLMessage, Performative
class BDICommunicator:
def __init__(self, agent_id: str, mental_state_store: BDIMentalStateStore):
self.agent_id = agent_id
self.store = mental_state_store
def share_belief(self, belief_uri: str, receiver: str) -> ACLMessage:
"""Create INFORM message to share belief."""
belief_triples = self.store.get_belief_as_turtle(belief_uri)
message = ACLMessage()
message.performative = Performative.INFORM
message.sender = self.agent_id
message.receiver = receiver
message.content = belief_triples
message.ontology = "https://w3id.org/fossr/ontology/bdi/"
message.language = "turtle"
return message
def request_belief_confirmation(self, belief_uri: str, receiver: str) -> ACLMessage:
"""Create QUERY-IF message to confirm shared belief."""
message = ACLMessage()
message.performative = Performative.QUERY_IF
message.sender = self.agent_id
message.receiver = receiver
message.content = f"ASK {{ <{belief_uri}> a bdi:Belief }}"
message.language = "sparql"
return message
def propose_intention(self, intention_uri: str, receiver: str) -> ACLMessage:
"""Create PROPOSE message for coordinated intention."""
intention_triples = self.store.get_intention_as_turtle(intention_uri)
message = ACLMessage()
message.performative = Performative.PROPOSE
message.sender = self.agent_id
message.receiver = receiver
message.content = intention_triples
message.ontology = "https://w3id.org/fossr/ontology/bdi/"
return messageBDI RDF Examples
Complete RDF/Turtle examples for BDI mental state modeling.
Complete Cognitive Workflow
@prefix bdi: <https://w3id.org/fossr/ontology/bdi/> .
@prefix ex: <http://example.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
# ============================================================
# PHASE 1: World State Perception
# ============================================================
ex:WorldState_traffic a bdi:WorldState ;
rdfs:comment "Heavy traffic on Route 101" ;
bdi:atTime "2026-01-04T08:30:00"^^xsd:dateTime ;
bdi:isPerceivedBy ex:Agent_commuter ;
bdi:triggers ex:BeliefProcess_assess_traffic .
# ============================================================
# PHASE 2: Belief Formation
# ============================================================
ex:BeliefProcess_assess_traffic a bdi:BeliefProcess ;
bdi:generates ex:Belief_traffic_delay ;
bdi:reasonsUpon ex:WorldState_traffic ;
bdi:isProcessedBy ex:Agent_commuter ;
bdi:atTime "2026-01-04T08:31:00"^^xsd:dateTime .
ex:Belief_traffic_delay a bdi:Belief ;
rdfs:label "Traffic will cause 30-minute delay" ;
bdi:refersTo ex:WorldState_traffic ;
bdi:hasValidity ex:TimeInterval_morning_commute ;
bdi:hasPart ex:Belief_route_congested , ex:Belief_delay_duration ;
bdi:isJustifiedBy ex:Justification_traffic_report ;
bdi:motivates ex:Desire_arrive_on_time .
ex:Belief_route_congested a bdi:Belief ;
rdfs:comment "Route 101 is congested" .
ex:Belief_delay_duration a bdi:Belief ;
rdfs:comment "Delay estimated at 30 minutes" .
ex:Justification_traffic_report a bdi:Justification ;
rdfs:label "Real-time traffic data from navigation system" ;
bdi:justifies ex:Belief_traffic_delay .
# ============================================================
# PHASE 3: Desire Formation
# ============================================================
ex:DesireProcess_plan_arrival a bdi:DesireProcess ;
bdi:generates ex:Desire_arrive_on_time ;
bdi:reasonsUpon ex:Belief_traffic_delay ;
bdi:isProcessedBy ex:Agent_commuter .
ex:Desire_arrive_on_time a bdi:Desire ;
rdfs:label "I desire to arrive at work on time" ;
bdi:isMotivatedBy ex:Belief_traffic_delay ;
bdi:refersTo ex:WorldState_on_time_arrival .
# ============================================================
# PHASE 4: Intention Commitment
# ============================================================
ex:IntentionProcess_commit_route a bdi:IntentionProcess ;
bdi:generates ex:Intention_take_alternate_route ;
bdi:reasonsUpon ex:Desire_arrive_on_time ;
bdi:isProcessedBy ex:Agent_commuter .
ex:Intention_take_alternate_route a bdi:Intention ;
rdfs:label "I will take alternate route via Highway 280" ;
bdi:fulfils ex:Desire_arrive_on_time ;
bdi:isSupportedBy ex:Belief_traffic_delay ;
bdi:specifies ex:Plan_alternate_commute ;
bdi:isJustifiedBy ex:Justification_time_optimization .
ex:Justification_time_optimization a bdi:Justification ;
rdfs:label "Alternate route saves 20 minutes based on current conditions" ;
bdi:justifies ex:Intention_take_alternate_route .
# ============================================================
# PHASE 5: Planning
# ============================================================
ex:Planning_route_selection a bdi:Planning ;
bdi:reasonsUpon ex:Intention_take_alternate_route ;
bdi:defines ex:Plan_alternate_commute ;
bdi:atTime ex:TimeInterval_planning_phase .
ex:Plan_alternate_commute a bdi:Plan ;
rdfs:label "Alternate commute via Highway 280" ;
bdi:addresses ex:Goal_arrive_by_9am ;
bdi:beginsWith ex:Task_exit_Route101 ;
bdi:endsWith ex:Task_arrive_parking ;
bdi:hasComponent ex:Task_exit_Route101 , ex:Task_merge_280 ,
ex:Task_navigate_280 , ex:Task_arrive_parking .
ex:Task_exit_Route101 a bdi:Task ;
rdfs:label "Exit Route 101 at Whipple Ave" ;
bdi:precedes ex:Task_merge_280 .
ex:Task_merge_280 a bdi:Task ;
rdfs:label "Merge onto Highway 280 North" ;
bdi:precedes ex:Task_navigate_280 .
ex:Task_navigate_280 a bdi:Task ;
rdfs:label "Continue on Highway 280 for 8 miles" ;
bdi:precedes ex:Task_arrive_parking .
ex:Task_arrive_parking a bdi:Task ;
rdfs:label "Arrive at office parking garage" .
ex:Goal_arrive_by_9am a bdi:Goal ;
rdfs:label "Arrive at work by 9:00 AM" .
# ============================================================
# PHASE 6: Plan Execution
# ============================================================
ex:PlanExecution_commute a bdi:PlanExecution ;
bdi:satisfies ex:Plan_alternate_commute ;
bdi:addresses ex:Goal_arrive_by_9am ;
bdi:isExecutedBy ex:Agent_commuter ;
bdi:hasComponent ex:Action_exit , ex:Action_merge ,
ex:Action_drive_280 , ex:Action_park ;
bdi:atTime ex:TimeInterval_execution ;
bdi:bringsAbout ex:WorldState_arrived_on_time .
ex:Action_exit a bdi:Action ;
bdi:isExecutionOf ex:Task_exit_Route101 ;
bdi:isPerformedBy ex:Agent_commuter ;
bdi:atTime "2026-01-04T08:35:00"^^xsd:dateTime .
ex:Action_merge a bdi:Action ;
bdi:isExecutionOf ex:Task_merge_280 ;
bdi:isPerformedBy ex:Agent_commuter ;
bdi:atTime "2026-01-04T08:37:00"^^xsd:dateTime .
ex:Action_drive_280 a bdi:Action ;
bdi:isExecutionOf ex:Task_navigate_280 ;
bdi:isPerformedBy ex:Agent_commuter ;
bdi:atTime "2026-01-04T08:40:00"^^xsd:dateTime .
ex:Action_park a bdi:Action ;
bdi:isExecutionOf ex:Task_arrive_parking ;
bdi:isPerformedBy ex:Agent_commuter ;
bdi:bringsAbout ex:WorldState_arrived_on_time ;
bdi:atTime "2026-01-04T08:52:00"^^xsd:dateTime .
# ============================================================
# PHASE 7: Resulting World State
# ============================================================
ex:WorldState_arrived_on_time a bdi:WorldState ;
rdfs:comment "Agent arrived at work at 8:52 AM" ;
bdi:atTime "2026-01-04T08:52:00"^^xsd:dateTime .
# ============================================================
# TEMPORAL INTERVALS
# ============================================================
ex:TimeInterval_morning_commute a bdi:TimeInterval ;
bdi:hasStartTime "2026-01-04T08:30:00"^^xsd:dateTime ;
bdi:hasEndTime "2026-01-04T09:00:00"^^xsd:dateTime .
ex:TimeInterval_planning_phase a bdi:TimeInterval ;
bdi:hasStartTime "2026-01-04T08:31:00"^^xsd:dateTime ;
bdi:hasEndTime "2026-01-04T08:34:00"^^xsd:dateTime .
ex:TimeInterval_execution a bdi:TimeInterval ;
bdi:hasStartTime "2026-01-04T08:35:00"^^xsd:dateTime ;
bdi:hasEndTime "2026-01-04T08:52:00"^^xsd:dateTime .Multi-Agent Coordination Example
@prefix bdi: <https://w3id.org/fossr/ontology/bdi/> .
@prefix ex: <http://example.org/> .
@prefix fipa: <http://www.fipa.org/specs/fipa00061/> .
# Shared belief about project deadline
ex:Agent_developer a bdi:Agent ;
bdi:hasMentalState ex:Belief_deadline_friday .
ex:Agent_manager a bdi:Agent ;
bdi:hasMentalState ex:Belief_deadline_friday .
ex:Belief_deadline_friday a bdi:Belief ;
rdfs:label "Project deadline is Friday 5 PM" ;
bdi:refersTo ex:WorldState_deadline ;
bdi:hasValidity ex:TimeInterval_project_week .
ex:WorldState_deadline a bdi:WorldState ;
rdfs:comment "Project XYZ must be delivered by 2026-01-10T17:00:00" .
# Agent-specific mental states
ex:Agent_developer
bdi:hasDesire ex:Desire_complete_coding ;
bdi:hasIntention ex:Intention_implement_features .
ex:Desire_complete_coding a bdi:Desire ;
rdfs:label "Complete feature implementation" ;
bdi:isMotivatedBy ex:Belief_deadline_friday .
ex:Intention_implement_features a bdi:Intention ;
rdfs:label "Implement features A, B, and C" ;
bdi:fulfils ex:Desire_complete_coding ;
bdi:specifies ex:Plan_development .
ex:Agent_manager
bdi:hasDesire ex:Desire_ensure_delivery ;
bdi:hasIntention ex:Intention_coordinate_team .
ex:Desire_ensure_delivery a bdi:Desire ;
rdfs:label "Ensure on-time project delivery" ;
bdi:isMotivatedBy ex:Belief_deadline_friday .
ex:Intention_coordinate_team a bdi:Intention ;
rdfs:label "Coordinate team activities" ;
bdi:fulfils ex:Desire_ensure_delivery ;
bdi:specifies ex:Plan_project_management .
# FIPA communication
ex:Message_M1 a fipa:ACLMessage ;
fipa:sender ex:Agent_manager ;
fipa:receiver ex:Agent_developer ;
fipa:content ex:Belief_deadline_friday ;
fipa:performative fipa:inform .Conflict Resolution Example
@prefix bdi: <https://w3id.org/fossr/ontology/bdi/> .
@prefix ex: <http://example.org/> .
# Conflicting location beliefs
ex:Belief_at_home a bdi:Belief ;
bdi:refersTo ex:WorldState_home ;
rdfs:comment "Agent is currently at home" .
ex:Belief_at_office a bdi:Belief ;
bdi:refersTo ex:WorldState_office ;
rdfs:comment "Agent is at office" .
# Conflicting intentions
ex:Intention_work_from_home a bdi:Intention ;
bdi:isSupportedBy ex:Belief_at_home ;
rdfs:label "Work from home today" .
ex:Intention_attend_meeting a bdi:Intention ;
bdi:isSupportedBy ex:Belief_at_office ;
rdfs:label "Attend in-person meeting" .
# Justification for conflict resolution
ex:Justification_location_conflict a bdi:Justification ;
rdfs:comment "Cannot simultaneously be at home and office" ;
bdi:justifies ex:Intention_resolution .
# Resolved intention
ex:Intention_resolution a bdi:Intention ;
rdfs:label "Attend meeting via video call from home" ;
bdi:fulfils ex:Desire_meeting_participation ;
bdi:isSupportedBy ex:Belief_at_home ;
bdi:isJustifiedBy ex:Justification_location_conflict .T2B2T Payment Processing Example
@prefix bdi: <https://w3id.org/fossr/ontology/bdi/> .
@prefix ex: <http://example.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
# PHASE 1: Triples-to-Beliefs (External RDF → Internal Mental State)
ex:WorldState_notification a bdi:WorldState ;
rdfs:comment "Push notification: Ghadeh requested $250 via Zelle" ;
bdi:atTime "2025-10-27T10:15:00"^^xsd:dateTime ;
bdi:triggers ex:BeliefProcess_BP1 .
ex:BeliefProcess_BP1 a bdi:BeliefProcess ;
bdi:generates ex:Belief_payment_request ;
bdi:isProcessedBy ex:Agent_A .
ex:Belief_payment_request a bdi:Belief ;
rdfs:label "Ghadeh requested $250" ;
bdi:refersTo ex:WorldState_notification ;
bdi:motivates ex:Desire_pay_Ghadeh .
ex:Desire_pay_Ghadeh a bdi:Desire ;
rdfs:label "Pay Ghadeh $250" ;
bdi:isMotivatedBy ex:Belief_payment_request .
ex:Intention_I1 a bdi:Intention ;
rdfs:label "Pay Ghadeh $250" ;
bdi:fulfils ex:Desire_pay_Ghadeh ;
bdi:specifies ex:Plan_payment .
# PHASE 2: Beliefs-to-Triples (Mental State → External RDF)
ex:PlanExecution_PE1 a bdi:PlanExecution ;
bdi:satisfies ex:Plan_payment ;
bdi:bringsAbout ex:WorldState_payment_complete .
ex:WorldState_payment_complete a bdi:WorldState ;
rdfs:comment "Payment of $250 sent to Ghadeh via Zelle" ;
bdi:atTime "2025-10-27T10:20:00"^^xsd:dateTime .SPARQL Competency Queries
Validation queries for BDI ontology implementations based on competency questions.
Mental Entity Queries
CQ1: What are all mental entities?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?entity ?type WHERE {
?entity rdf:type ?type .
?type rdfs:subClassOf* bdi:MentalEntity .
}CQ2: What beliefs does an agent hold?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?belief ?label WHERE {
?agent bdi:hasMentalState ?belief .
?belief a bdi:Belief .
OPTIONAL { ?belief rdfs:label ?label }
}CQ3: What desires does an agent have?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?desire ?label WHERE {
?agent bdi:hasDesire ?desire .
?desire a bdi:Desire .
OPTIONAL { ?desire rdfs:label ?label }
}CQ4: What intentions has an agent committed to?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?intention ?label WHERE {
?agent bdi:hasIntention ?intention .
?intention a bdi:Intention .
OPTIONAL { ?intention rdfs:label ?label }
}Motivational Chain Queries
CQ5: What beliefs motivated formation of a given desire?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?belief ?beliefLabel WHERE {
?desire bdi:isMotivatedBy ?belief .
?belief a bdi:Belief .
OPTIONAL { ?belief rdfs:label ?beliefLabel }
}CQ6: Which desire does a particular intention fulfill?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?desire ?desireLabel WHERE {
?intention bdi:fulfils ?desire .
?desire a bdi:Desire .
OPTIONAL { ?desire rdfs:label ?desireLabel }
}CQ7: What beliefs support a given intention?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?belief ?label WHERE {
?intention bdi:isSupportedBy ?belief .
?belief a bdi:Belief .
OPTIONAL { ?belief rdfs:label ?label }
}CQ8: Trace complete cognitive chain for an intention
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?intention ?desire ?belief ?worldState WHERE {
?intention a bdi:Intention ;
bdi:fulfils ?desire ;
bdi:isSupportedBy ?belief .
?desire bdi:isMotivatedBy ?belief .
?belief bdi:refersTo ?worldState .
}Mental Process Queries
CQ9: Which mental process generated a belief?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?process ?processType WHERE {
?process bdi:generates ?belief .
?belief a bdi:Belief .
?process a ?processType .
FILTER(?processType != owl:NamedIndividual)
}CQ10: What triggered a mental process?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?process ?trigger ?triggerType WHERE {
?process a bdi:MentalProcess ;
bdi:isTriggeredBy ?trigger .
?trigger a ?triggerType .
}CQ11: What did a mental process reason upon?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?process ?input WHERE {
?process a bdi:MentalProcess ;
bdi:reasonsUpon ?input .
}Plan and Goal Queries
CQ12: What plan does an intention specify?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?intention ?plan ?goal WHERE {
?intention bdi:specifies ?plan .
?plan a bdi:Plan ;
bdi:addresses ?goal .
}CQ13: What is the ordered sequence of tasks in a plan?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?plan ?task ?nextTask WHERE {
?plan a bdi:Plan ;
bdi:hasComponent ?task .
OPTIONAL { ?task bdi:precedes ?nextTask }
}
ORDER BY ?taskCQ14: What is the first and last task of a plan?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?plan ?firstTask ?lastTask WHERE {
?plan a bdi:Plan ;
bdi:beginsWith ?firstTask ;
bdi:endsWith ?lastTask .
}CQ15: Which actions executed which tasks?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?action ?task ?time WHERE {
?action bdi:isExecutionOf ?task ;
bdi:atTime ?time .
}
ORDER BY ?timeTemporal Queries
CQ16: What mental states are valid at a specific time?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?mentalState ?type WHERE {
?mentalState bdi:hasValidity ?interval .
?interval bdi:hasStartTime ?start ;
bdi:hasEndTime ?end .
?mentalState a ?type .
FILTER(?start <= "2026-01-04T10:00:00"^^xsd:dateTime &&
?end >= "2026-01-04T10:00:00"^^xsd:dateTime)
}CQ17: When was a belief formed?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?belief ?formationTime WHERE {
?process bdi:generates ?belief ;
bdi:atTime ?formationTime .
?belief a bdi:Belief .
}CQ18: What is the temporal validity of an intention?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?intention ?start ?end WHERE {
?intention a bdi:Intention ;
bdi:hasValidity ?interval .
?interval bdi:hasStartTime ?start ;
bdi:hasEndTime ?end .
}Justification Queries
CQ19: What justifies a belief?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?belief ?justification ?justLabel WHERE {
?belief a bdi:Belief ;
bdi:isJustifiedBy ?justification .
OPTIONAL { ?justification rdfs:label ?justLabel }
}CQ20: What justifies an intention?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?intention ?justification ?justLabel WHERE {
?intention a bdi:Intention ;
bdi:isJustifiedBy ?justification .
OPTIONAL { ?justification rdfs:label ?justLabel }
}Compositional Queries
CQ21: What parts comprise a complex belief?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?belief ?part ?partLabel WHERE {
?belief a bdi:Belief ;
bdi:hasPart ?part .
OPTIONAL { ?part rdfs:label ?partLabel }
}CQ22: Find composite mental entities
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?composite (COUNT(?part) AS ?partCount) WHERE {
?composite bdi:hasPart ?part .
}
GROUP BY ?composite
HAVING (COUNT(?part) > 1)World State Queries
CQ23: What world state does a belief refer to?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?belief ?worldState ?wsComment WHERE {
?belief a bdi:Belief ;
bdi:refersTo ?worldState .
OPTIONAL { ?worldState rdfs:comment ?wsComment }
}CQ24: What actions brought about a world state?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?action ?worldState WHERE {
?action bdi:bringsAbout ?worldState .
?worldState a bdi:WorldState .
}CQ25: What world states has an agent perceived?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?agent ?worldState ?time WHERE {
?agent bdi:perceives ?worldState .
OPTIONAL { ?worldState bdi:atTime ?time }
}Validation Queries (OWLUnit Style)
V1: Every intention must fulfill exactly one desire
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?intention WHERE {
?intention a bdi:Intention .
FILTER NOT EXISTS { ?intention bdi:fulfils ?desire }
}
# Expected: Empty result setV2: Every belief must reference a world state
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?belief WHERE {
?belief a bdi:Belief .
FILTER NOT EXISTS { ?belief bdi:refersTo ?worldState }
}
# Expected: Empty result set (or only abstract beliefs)V3: Mental processes must reason upon something
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?process WHERE {
?process a bdi:MentalProcess .
FILTER NOT EXISTS { ?process bdi:reasonsUpon ?input }
}
# Expected: Empty result setV4: BeliefProcess must generate only Beliefs
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?process ?generated WHERE {
?process a bdi:BeliefProcess ;
bdi:generates ?generated .
FILTER NOT EXISTS { ?generated a bdi:Belief }
}
# Expected: Empty result setV5: Plans must have begin and end tasks
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?plan WHERE {
?plan a bdi:Plan .
FILTER NOT EXISTS {
?plan bdi:beginsWith ?first ;
bdi:endsWith ?last
}
}
# Expected: Empty result setMulti-Agent Queries
CQ26: What beliefs are shared across agents?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?belief (COUNT(DISTINCT ?agent) AS ?agentCount) WHERE {
?agent bdi:hasMentalState ?belief .
?belief a bdi:Belief .
}
GROUP BY ?belief
HAVING (COUNT(DISTINCT ?agent) > 1)CQ27: Which agents share the same desire?
PREFIX bdi: <https://w3id.org/fossr/ontology/bdi/>
SELECT ?desire ?agent1 ?agent2 WHERE {
?agent1 bdi:hasDesire ?desire .
?agent2 bdi:hasDesire ?desire .
FILTER(?agent1 != ?agent2)
}