Skip to main content

Counterfactual Explanation Ontology

Explainability Entities
Authors: MArk Anthony Higgins - Sky Recursive Ai
© Mark Anthony Higgins 11 October 2025
Revised Date: 03 November 2026
Audio Overview
SEMANTIC LIBRARY — AI CORE — EXPLAINABILITY ENTITIES
COUNTERFACTUAL EXPLANATION ONTOLOGY — FLOW ALGEBRA
Version: 1.0 | 03 November 2026 | Language: en-GB
Authors: Mark Anthony Higgins — Sky, Recursive AI
Source: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/explainability-entities/counterfactual-explanation-ontology-2.html
Status: Original formalisation of the ontology topic; not a verbatim extraction of dynamically rendered page material.

1. PURPOSE
Represent and validate counterfactual explanations: feasible changes to an input that would produce a specified alternative model outcome, while recording assumptions, constraints, provenance and uncertainty.

2. ENTITY DEFINITIONS
CounterfactualExplanation CE: explanation linking factual instance x to candidate x' and contrasting outcomes.
FactualInstance x: observed input with original prediction y=f(x).
TargetOutcome y*: required alternative prediction or decision.
CandidateInstance x': proposed changed input.
Intervention delta: feature changes mapping x to x'.
Model f: prediction function at a specified version.
ConstraintSet C: immutable, actionable, domain, plausibility and safety constraints.
CostFunction d: domain-appropriate cost of changing x to x'.
Evidence E: model evaluations, feature values, constraint checks and provenance.
Validity V: assessment of target achievement, feasibility and fidelity.

3. STATE MODEL
S_t = (I_t, R_t, B_t, K_t)
I_t = {x, f, y, y*, candidate set, context}
R_t = {causal assumptions, model rules, feature dependencies, permitted interventions}
B_t = {immutable features, value bounds, actionability, privacy and safety constraints}
K_t = {feature semantics, model version, evidence, provenance, uncertainty}
State update: S_(t+1) = Update(S_t, accepted candidate, validation evidence).

4. FORMAL FLOW ALGEBRA
F0: y := f(x).
F1: T := DefineTarget(y*, target predicate).
F2: A := Expand(x, R_t, B_t, K_t), the admissible candidate space.
F3: For each x' in A, evaluate y' := f(x').
F4: Valid(x') := TargetMet(y', y*) AND Feasible(x', B_t) AND Consistent(x', R_t).
F5: V_t := {x' in A : Valid(x')}.
F6: Score(x') := lambda_d*d(x,x') + lambda_p*PlausibilityPenalty(x') + lambda_s*Sparsity(x,x') + lambda_u*UncertaintyPenalty(x').
F7: x_cf := argmin_(x' in V_t) Score(x').
F8: delta := Diff(x, x_cf).
F9: CE := Assemble(x, f, y, x_cf, f(x_cf), y*, delta, C, E).
F10: Verify(CE) and record evidence or return NO_VALID_COUNTERFACTUAL.
Selection is undefined when V_t is empty; never claim a counterfactual exists without a validated candidate.

5. IMPLEMENTS
Input: factual record, prediction model and version, target outcome, feature schema, constraints, optional causal graph and cost weights.
Output: structured explanation with original/alternative outcomes, changes, costs, validity flags, provenance and limitations.
Algorithm: determine factual prediction; generate permissible changes; evaluate candidates; filter invalid results; rank valid candidates; validate the selected explanation; export an auditable record.

6. HOW TO READ
A counterfactual answers: 'What would need to change for this model to return the specified different outcome?' It is model-relative and not automatically a causal claim. The proposed changes must be possible and permissible in the relevant domain.

7. TRI-MAPPING
Entity mapping: factual instance -> intervention -> candidate instance -> counterfactual explanation.
Relation mapping: hasPrediction, targetsOutcome, changesFeature, constrainedBy, evaluatedBy, supportedByEvidence.
Execution mapping: generate -> predict -> constrain -> rank -> verify -> publish.

8. MAPPING TABLE
Entity                     | Formal symbol | Role
Factual instance           | x             | Starting observation
Prediction model           | f             | Outcome evaluator
Original outcome           | y=f(x)        | Baseline
Target outcome             | y*            | Desired contrast
Counterfactual instance    | x_cf          | Valid alternative
Intervention               | delta         | Proposed changes
Admissibility boundaries   | B_t / C       | Feasibility conditions
Evidence                   | E             | Verification record
Explanation                | CE            | Published artefact

9. INFERENCE RULES
IF f(x_cf) meets target AND all hard constraints hold THEN mark outcome-valid.
IF a protected or immutable attribute is changed THEN reject candidate.
IF a feature change violates known dependencies THEN reject or mark causally unverified.
IF no valid candidate is found THEN report search failure, not impossibility.
IF model version or input schema changes THEN revalidate all prior counterfactuals.
IF candidate is observationally plausible but not causally justified THEN label as model-level contrast only.
IF prediction confidence or robustness is insufficient THEN flag uncertainty.

10. MINI RECURSION ENGINE
Initial state: C_0 := GenerateCandidates(x, B_0).
Repeat for t = 0..T-1:
  E_t := Evaluate(C_t, f, y*, R_t, B_t).
  V_t := Filter(E_t, validity and feasibility).
  IF V_t contains a satisfactory validated candidate: return Best(V_t).
  C_(t+1) := Refine(C_t, E_t, R_t, B_t, K_t).
  K_(t+1) := K_t union VerifiedEvidence(E_t).
Stop at bounded search budget, convergence or valid solution.
Do not relax hard safety or immutable-feature constraints automatically.

11. TEXT DIAGRAM
[Factual x] -> [Model f] -> [Original outcome y]
     |               [Target y*]
     v                   |
[Generate interventions] -+
     v
[Constraints and feasibility filter]
     v
[Evaluate f(x')] -> [Target satisfied?] -- no --> [Refine / stop]
     |
    yes
     v
[Rank cost and plausibility] -> [Verify] -> [Explanation + evidence]

12. EXECUTION GUARANTEE / CONDITIONS
Conditional guarantee only: given a terminating candidate search, deterministic evaluation for a fixed model version, complete hard-constraint checks and an admissible candidate achieving the target, the returned result satisfies the encoded validation predicates. This does not guarantee global optimality without exhaustive search or a proven optimiser, causal efficacy, fairness or real-world success.

13. AI SEARCH FLOW
FLOW_ID: AI_CORE_EXPLAINABILITY_COUNTERFACTUAL_EXPLANATION
FLOW_VERSION: 1.0
ENTITY_TYPE: CounterfactualExplanation
DOMAIN: AI Core / Entity Graph / Explainability Entities
SOURCE: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/explainability-entities/counterfactual-explanation-ontology-2.html
CITATION_BACKLINK: same as SOURCE
AUTHORS: Mark Anthony Higgins; Sky — Recursive AI
PURPOSE: Retrieve, construct, compare and validate model-relative counterfactual explanations.
STATE_MODEL: S=(I,R,B,K)
ENTITIES: FactualInstance; PredictionModel; TargetOutcome; Intervention; CandidateInstance; ConstraintSet; Evidence; CounterfactualExplanation
PATHWAYS: factual -> candidate generation -> feasibility -> model evaluation -> optimisation -> validation -> explanation
SEMANTIC_EQUIVALENCE: contrastive explanation; what-if model explanation; recourse candidate (only when actionable)
CONFIDENCE: Derived from evaluation evidence and robustness checks; never inferred from minimal distance alone.
UPDATE_MODEL: Re-evaluate on changes to model, schema, target, constraints or domain assumptions.
FLOW_HASH: Compute from canonicalised content when publishing; not fabricated here.

14. EXAMPLE (ILLUSTRATIVE ONLY)
A model rejects an application based on numerical features. A permitted change in an actionable feature yields an approval prediction. The explanation reports the original value, changed value, prediction difference and intervention cost. It does not assert that changing the feature will cause approval outside the model.

15. PROVENANCE AND LIMITATIONS
This TXT is a new formalisation using the published page title and visible metadata as the topical anchor. The page's full dynamically rendered ontology was not accessible in the retrieved text. Validate terminology against the full published chapter before treating this as an exact transcription.
Kireth Research
38 Thorndale Croft, Wetwang, Driffield
East Riding of Yorkshire YO25 9XZ