FLOW ALGEBRA — DRUG ONTOLOGY
Semantic Library | Biological Entities | Pharmacological and Therapeutic Entities
Version: 1.0 | 2026-10-27 | Encoding: UTF-8
Authors: Mark Anthony Higgins; Sky — Recursive AI
Source: https://kirethresearch.org/booksai-core/entity-graph/biological-entities/pharmacological-and-therapeutic-entities/drug-ontology.html
Status: Original companion formalisation; the source page's full embedded rules were not available in the retrieved page text.
Purpose: Represent drug entities, evidence, actions, dispositions, and safety constraints as auditable semantic flows; not a prescribing engine.
1. ENTITY MODEL
Drug := (id, names, ingredient_set, formulation, strength, route, legal_status, provenance)
Ingredient := (id, chemical_or_biological_identity, active_flag)
Formulation := (dosage_form, excipients, release_profile)
Target := (id, target_type, species, tissue_context)
Interaction := (drug_a, drug_b_or_substance, mechanism, clinical_significance, evidence)
Indication := (drug, condition, population, jurisdiction, authorisation, evidence)
Contraindication := (drug, condition_or_context, severity, evidence)
AdverseEvent := (drug, event, frequency, severity, causality_status, evidence)
Exposure := (drug, dose, route, schedule, time, population_context)
Evidence := (source_id, design, date, population, uncertainty, quality)
All assertions carry source and temporal context; unknown is not false.
2. STATE MODEL
S_t = (I_t, R_t, B_t, K_t)
I_t := known entities, observations, queries and evidence at time t
R_t := typed semantic and mechanistic relations
B_t := safety, validity, jurisdiction, time and scope boundaries
K_t := established knowledge, confidence and provenance
E_t = expand(I_t, R_t)
V_t = {x in E_t | satisfies(x, B_t) AND provenance_valid(x)}
x*_t = argmax_{x in V_t} P(x | I_t, R_t, B_t, K_t)
I_(t+1) = update(I_t, x*_t, new_evidence)
NOTE: P is a ranking abstraction, not a calibrated clinical probability unless separately validated.
3. ENTITY TYPES
DRUG; ACTIVE_INGREDIENT; EXCIPIENT; BRAND_NAME; GENERIC_NAME
FORMULATION; DOSE_STRENGTH; ROUTE; REGIMEN; DRUG_CLASS
MOLECULAR_TARGET; MECHANISM_OF_ACTION; PHARMACOLOGICAL_EFFECT
INDICATION; CONTRAINDICATION; PRECAUTION; ADVERSE_EVENT
DRUG_INTERACTION; METABOLITE; TRANSPORTER; ENZYME
PHARMACOKINETIC_PROFILE; PHARMACODYNAMIC_PROFILE
REGULATORY_AUTHORISATION; CLINICAL_EVIDENCE; POPULATION
4. TYPED RELATIONS
HAS_ACTIVE_INGREDIENT(Drug, Ingredient)
HAS_FORMULATION(Drug, Formulation)
HAS_ROUTE(Drug, Route)
MEMBER_OF_CLASS(Drug, DrugClass)
ACTS_ON(Ingredient, Target)
HAS_MECHANISM(Ingredient, Mechanism)
PRODUCES_EFFECT(Mechanism, Effect)
HAS_INDICATION(Drug, Indication)
HAS_CONTRAINDICATION(Drug, Contraindication)
MAY_CAUSE(Drug, AdverseEvent)
INTERACTS_WITH(Drug, DrugOrSubstance)
METABOLISED_BY(Ingredient, Enzyme)
TRANSPORTED_BY(Ingredient, Transporter)
HAS_EVIDENCE(Assertion, Evidence)
AUTHORISED_IN(DrugFormulation, Jurisdiction)
5. INVARIANTS
INV01: Drug identity is not interchangeable with a brand name.
INV02: Same ingredient does not imply equivalent formulation, strength, route or release profile.
INV03: Mechanistic plausibility does not establish clinical efficacy.
INV04: Association with an adverse event does not alone establish causality.
INV05: An indication is population-, jurisdiction- and time-dependent.
INV06: Absence of a known interaction is not proof of no interaction.
INV07: Contraindications and safety evidence override relevance ranking.
INV08: Unknown and conflicting evidence must remain explicitly represented.
INV09: No dosage or treatment recommendation follows solely from ontology inference.
INV10: Provenance, version and effective date are preserved on updates.
6. PATHWAYS
P1 IDENTIFICATION:
input(name) -> normalise_synonyms -> resolve_drug_identity -> verify_ingredient_and_formulation
P2 MECHANISM:
ingredient -> target -> mechanism -> effect -> evidence_check
P3 CLINICAL_CONTEXT:
drug -> indication -> population -> authorisation -> evidence_check
P4 SAFETY:
drug -> contraindication/interaction/adverse_event -> severity -> evidence -> flag
P5 DISPOSITION:
drug -> absorption -> distribution -> metabolism -> excretion -> context
P6 UPDATE:
new_source -> provenance_validation -> assertion_comparison -> versioned_revision
7. INFERENCE RULES
R01 IF HAS_ACTIVE_INGREDIENT(d,a) AND ACTS_ON(a,t)
THEN candidate_relation(d, ACTS_ON, t), status=derived.
R02 IF HAS_MECHANISM(a,m) AND PRODUCES_EFFECT(m,e)
THEN candidate_effect(a,e), status=hypothesis_until_supported.
R03 IF HAS_INDICATION(d,i) AND evidence_supports(i,p,j,t)
THEN indication_applicability(d,i,p,j,t), status=contextual.
R04 IF contraindication_applies(d,c,p)
THEN flag(d, 'contraindication_requires_clinical_review').
R05 IF interaction_applies(d1,d2,p)
THEN flag((d1,d2), 'interaction_requires_clinical_review').
R06 IF conflicting_sources(assertion)
THEN mark(assertion, contested); preserve_all_sources.
R07 IF evidence_missing(assertion)
THEN mark(assertion, unverified); prohibit_clinical_conclusion.
R08 IF formulation_or_route_differs(d1,d2)
THEN prohibit_automatic_equivalence(d1,d2).
8. MINI RECURSION ENGINE
function semantic_step(state):
candidates := expand(state.I, state.R)
candidates := filter(candidates, state.B)
annotate(candidates, provenance, confidence, conflict, uncertainty)
if any_safety_flag(candidates): return REVIEW_REQUIRED
if no_supported_candidates(candidates): return INSUFFICIENT_EVIDENCE
selected := rank_supported(candidates, state.K)
return update_state(state, selected)
termination := fixed_point OR depth_limit OR insufficient_evidence OR safety_review
No recursion may silently remove safety flags or convert uncertainty into certainty.
9. TRI-MAPPING
ONTOLOGY: Drug -> Ingredient -> Target -> Mechanism -> Effect
FLOW: identify -> expand -> constrain -> evaluate -> update
EVIDENCE: source -> claim -> population/context -> quality -> confidence
Mapping integrity requires every derived claim to retain an evidence trace.
10. AI SEARCH FLOW
QUERY -> INTENT_CLASSIFICATION -> ENTITY_RESOLUTION -> RELATION_EXPANSION
-> SAFETY_AND_CONTEXT_FILTER -> EVIDENCE_RANKING
-> EXPLAINABLE_OUTPUT -> PROVENANCE_LINKS
Intent classes: definition, classification, mechanism, comparison, safety, research.
For individual treatment/dosing queries: return general information and request qualified clinical review.
11. CONFIDENCE AND PROVENANCE
confidence := evidence_weight * source_relevance * context_match * consistency
All factors in [0,1]; illustrative only, not clinically calibrated.
Store: source_uri, citation, author, publication_date, access_date, jurisdiction,
evidence_design, population, version, derivation_path, limitations.
Never infer regulatory approval from a drug's presence in this ontology.
12. VALIDATION TESTS
T01 A trade name without ingredient resolution remains unresolved.
T02 Same ingredient, different release formulation: not automatically equivalent.
T03 Unsupported mechanism-to-benefit leap: rejected as established efficacy.
T04 Interaction warning: retained through every update cycle.
T05 Conflicting evidence: both claims retained with uncertainty markers.
T06 Unknown indication: no positive clinical recommendation produced.
T07 Missing source: assertion flagged unverified.
T08 Outdated authorisation: marked for jurisdiction-specific revalidation.
13. EXECUTION GUARANTEE (CONDITIONAL)
Given valid typed input, explicit bounds, finite search depth and provenance data,
this specification produces a deterministic trace of rule application under a
fixed ranking configuration. It does NOT guarantee clinical truth, completeness,
medical safety, or suitability for diagnosis, prescribing or treatment.
14. OUTPUT CONTRACT
output := {entity_id, resolved_name, classifications, relations, evidence,
confidence_status, safety_flags, unresolved_questions,
provenance, derivation_trace, ontology_version}
END FLOW ALGEBRA — DRUG ONTOLOGY
Download Code
Copy to Clipboard