FLOW ALGEBRA
TITLE: Carbohydrate Ontology
VERSION: 1.0
DOMAIN: Biological Entities / Macromolecular Entities
SOURCE: https://kirethresearch.org/booksai-core/entity-graph/biological-entities/macromolecular-entities/carbohydrate-ontology-2.html
AUTHORS: Mark Anthony Higgins — Sky (Recursive AI)
STATUS: Companion formalisation; declarative specification, not an independently verified executable implementation.
1. ONTOLOGY PURPOSE
Represent carbohydrates as typed chemical and biological entities, capturing composition, stereochemistry, linkages, polymer structure, function, context, evidence and inferential dependencies. Distinguish identity from structural similarity and biological role.
2. ENTITY TYPES
ENTITY Carbohydrate : ChemicalEntity
ENTITY Monosaccharide : Carbohydrate
ENTITY Disaccharide : Carbohydrate
ENTITY Oligosaccharide : Carbohydrate
ENTITY Polysaccharide : Carbohydrate
ENTITY Glycan : Carbohydrate
ENTITY SugarResidue : ChemicalSubstructure
ENTITY GlycosidicBond : ChemicalBond
ENTITY FunctionalGroup : ChemicalSubstructure
ENTITY Stereoisomer : ChemicalEntity
ENTITY Anomer : Stereoisomer
ENTITY Glycoconjugate : MolecularComplex
ENTITY Glycoprotein : Glycoconjugate
ENTITY Glycolipid : Glycoconjugate
ENTITY BiologicalProcess : Process
ENTITY Organism : BiologicalEntity
ENTITY EvidenceRecord : InformationEntity
3. CORE ATTRIBUTES
Carbohydrate: identifier, preferred_name, synonyms, formula?, mass?, structure?, stereochemistry?, charge?, biological_context?, provenance?
Monosaccharide: carbon_count?, carbonyl_class?, ring_form?, anomeric_configuration?, absolute_configuration?
Polysaccharide: residue_sequence?, linkage_pattern?, branching?, degree_of_polymerisation?, molecular_mass_distribution?
GlycosidicBond: donor_position?, acceptor_position?, anomeric_configuration?, bond_type?
EvidenceRecord: source_id, method, timestamp?, scope, quality_status
Unknown fields remain UNKNOWN, not inferred by default.
4. RELATIONSHIP TYPES
IS_A(child:Entity, parent:Entity)
HAS_COMPONENT(whole:Entity, part:Entity)
HAS_RESIDUE(polymer:Carbohydrate, residue:SugarResidue)
LINKED_BY(left:SugarResidue, right:SugarResidue, bond:GlycosidicBond)
HAS_STEREOCHEMISTRY(entity:Carbohydrate, configuration:Value)
HAS_STRUCTURE(entity:Carbohydrate, structure:Representation)
IS_STEREOISOMER_OF(a:ChemicalEntity, b:ChemicalEntity)
IS_ANOMER_OF(a:Monosaccharide, b:Monosaccharide)
PARTICIPATES_IN(entity:Carbohydrate, process:BiologicalProcess)
HAS_ROLE(entity:Carbohydrate, role:BiologicalRole, context:Context)
DERIVED_FROM(assertion:Assertion, evidence:EvidenceRecord)
SEMANTIC_EQUIVALENCE(a:Entity, b:Entity, scope:Context)
5. TAXONOMIC RULES
RULE T1: IS_A(x, Monosaccharide) -> IS_A(x, Carbohydrate).
RULE T2: IS_A(x, Disaccharide) -> IS_A(x, Carbohydrate).
RULE T3: IS_A(x, Oligosaccharide) -> IS_A(x, Carbohydrate).
RULE T4: IS_A(x, Polysaccharide) -> IS_A(x, Carbohydrate).
RULE T5: IS_A(x, Glycoprotein) -> IS_A(x, Glycoconjugate).
RULE T6: IS_A(x, Glycolipid) -> IS_A(x, Glycoconjugate).
NOTE: Category thresholds for oligosaccharides and polysaccharides vary by convention; record classification scheme rather than asserting a universal residue-count boundary.
6. STRUCTURAL REASONING
RULE S1: LINKED_BY(a,b,g) -> HAS_COMPONENT(g,a) AND HAS_COMPONENT(g,b), where HAS_COMPONENT here denotes bond endpoints, not molecular composition.
RULE S2: HAS_RESIDUE(p,r) -> HAS_COMPONENT(p,r).
RULE S3: Two carbohydrates with identical molecular formulae are NOT necessarily identical: stereochemistry, connectivity and linkage position must be checked.
RULE S4: Sequence identity without matching branching and glycosidic stereochemistry does NOT establish structural identity.
RULE S5: Polymer molecular mass may be a distribution; do not substitute a single exact mass without measurement context.
7. BIOCHEMICAL FUNCTION RULES
RULE F1: HAS_ROLE(x, energy_source, c) requires organismal or biochemical context c.
RULE F2: HAS_ROLE(x, structural_support, c) requires evidence for the relevant structure and organism.
RULE F3: PARTICIPATES_IN(x, glycosylation) does not alone establish a specific signalling function.
RULE F4: Glycan recognition is context-dependent on linkage, presentation and binding partner.
EXAMPLES: glucose as metabolic substrate; glycogen as energy storage; cellulose as structural polysaccharide; glycan moieties as recognition determinants. Examples are not exhaustive classifications.
8. SEMANTIC EQUIVALENCE
EQUIVALENCE_LEVELS:
exact_identity: same chemically specified entity, including relevant stereochemistry
structural_equivalence: same connectivity and stereochemical constraints in defined scope
class_equivalence: interchangeable class labels within a named classification scheme
functional_similarity: shared role, not identity
RULE E1: Exact identity requires compatible structural identifiers and no unresolved stereochemical conflicts.
RULE E2: Synonym matching is candidate generation only; verify structure and context.
RULE E3: Shared function does not imply molecular identity.
RULE E4: Conflicting structures block automatic equivalence until resolved.
9. VALIDATION
CHECK V1: Every entity has a unique identifier and declared type.
CHECK V2: Glycosidic linkage positions must be chemically meaningful for the participating residues.
CHECK V3: Chemical formula, charge and residue count must be mutually compatible where supplied.
CHECK V4: Anomer assignments require an applicable anomeric centre.
CHECK V5: Classification claims cite a declared taxonomy or convention.
CHECK V6: Biological functions are tied to an explicit organism, tissue or experimental context where relevant.
CHECK V7: Evidence must be traceable; missing evidence is flagged, not fabricated.
VALIDATION_STATE = PASS | FAIL | INDETERMINATE
10. INFERENCE AND RECURSION
INFERENCE(input_graph, rules, context) -> derived_assertions
Each inferred assertion stores rule_id, premise_ids, scope and provenance.
Recursive traversal may follow HAS_COMPONENT and IS_A with visited-node tracking and depth limits.
Cycles in compositional containment are invalid unless explicitly modelled as non-containment references.
No inference may promote similarity to identity without an equivalence proof.
11. CONFIDENCE
CONFIDENCE(assertion) = {score?:[0,1], method, evidence_ids, calibration_status, scope}
A numeric score is optional; UNKNOWN is permitted.
Formal deduction from verified premises carries logical validity conditional on those premises; empirical certainty is separate.
Conflicting or incomplete evidence yields INDETERMINATE pending resolution.
Never present confidence as a measured probability without a documented calibration method.
12. PROVENANCE
PROVENANCE(assertion) = {source_uri, source_version?, creator?, observed_at?, method?, transformations[], parent_assertions[]}
Retain the difference between direct observation, curated reference and machine inference.
Revisions preserve superseded records for auditability.
13. FLOW_HASH
FLOW_HASH = SHA256(canonical_serialisation(ontology_version, entity_ids, typed_relations, rules, source_versions))
Canonicalisation must define field order, Unicode normalisation, identifier handling and null representation.
The hash establishes content integrity, not scientific correctness.
14. UPDATE_MODEL
UPDATE_MODEL(change):
validate_schema(change)
identify_affected_entities_and_relations(change)
invalidate_dependent_inferences(change)
rerun_applicable_rules(change)
revalidate_assertions(change)
refresh_confidence_and_provenance(change)
recompute_FLOW_HASH(change)
publish_versioned_graph_if_valid(change)
Changes failing validation are quarantined for review.
15. AI_CONSUMPTION
AI_CONSUMPTION:
input: typed graph, declared context, ontology version, evidence records
operations: lookup, classification, structural comparison, constrained inference, validation
output: assertions with identifiers, rule traces, evidence, confidence and uncertainty
constraints: do not invent molecular structures, measurements or citations; distinguish chemical identity from functional similarity; expose unresolved ambiguity
16. EXAMPLE GRAPH
ENTITY glucose_1 : Monosaccharide
PROPERTY glucose_1.preferred_name = "D-glucose"
ENTITY glycogen_1 : Polysaccharide
RELATION HAS_ROLE(glycogen_1, energy_storage, animal_cell_context)
RELATION PARTICIPATES_IN(glucose_1, carbohydrate_metabolism)
NOTE: Illustrative entities and roles; these are not sample-specific experimental observations.
17. OUTPUT CONTRACT
RETURN {ontology_id, version, entities, relationships, inferred_assertions, validation_state, unresolved_conflicts, confidence, provenance, flow_hash, update_log}
END FLOW ALGEBRA
Download Code
Copy to Clipboard