GraviLogic: Bridging Differential Geometry and Optimal Transport for Counterfactual Trajectory Analysis
Abstract
Predictive accuracy alone does not characterize the internal geometry, stability, or structural failures of learned representations: models with comparable accuracy can exhibit disparate hidden dynamics under distribution shift, and post-hoc attribution evaluates only the endpoints of inference. We introduce GraviLogic, a differential-geometric XAI framework that formalizes model inference as a continuous trajectory γ(t) through latent space between a factual input and a counterfactual probe selected via constrained optimization (contrastivity, data-manifold plausibility, sparsity, feature relevance). The trajectory is characterized by geometric, sensitivity, and structural-dependency metrics, summarized in a single GraviLogic Score, and formulated as a basis for measuring transport cost between model-induced trajectories and geodesic reference paths under a Riemannian pullback metric built from the same encoder. Across five datasets and three model classes, models with near-identical accuracy exhibit up to a 94×difference in Jacobian sensitivity; Cognitive Mass identifies a feature (AveBedrms, California Housing) driving substantial internal change while receiving near-zero SHAP/LIME attribution; and a density-support signal from the same trajectory detects misclassification with AUC = 0.755 on a 17,898-sample pulsar benchmark, improving to F1 = 0.654 combined with curvature and Cognitive Mass. We report a negative finding—Jacobian sensitivity associates with misclassification in the opposite direction on this dataset—and connect trajectory diagnostics to dynamic optimal transport, positioning geodesic deviation as the excess representational cost a model incurs relative to the most efficient path between two decision states.