A query-optimal algorithm for finding counterfactuals
Guy Blanc, Caleb Koch, Jane Lange, Li-Yang Tan
Abstract
We design an algorithm for finding counterfactuals with strong theoretical guarantees on its performance. For any monotone model f : X d → 0, 1 and instance x ⋆ , our algorithm makes queries to f and returns an optimal counterfactual for x ⋆ : a nearest instance x ′ to x ⋆ for which f (x ′ ) = f (x ⋆ ). Here S(f ) is the sensitivity of f , a discrete analogue of the Lipschitz constant, and ∆ f (x ⋆ ) is the distance from x ⋆ to its nearest counterfactuals. The previous best known query complexity was d O(∆ f (x ⋆ )) , achievable by brute-force local search. We further prove a lower bound of S(f ) Ω(∆ f (x ⋆ )) + Ω(log d) on the query complexity of any algorithm, thereby showing that the guarantees of our algorithm are essentially optimal. Theorem 2. Given queries to a monotone model f : X d → 0, 1 with sensitivity S(f ) and an instance x ⋆ , our algorithm makes queries to f and w.h.p. returns the collection C f (x ⋆ ) = ∆(x ⋆ , x ′ ) : x ′ is an optimal counterfactual for x ⋆ . Theorems 1 and 2 give the first algorithms with query complexity that evades the curse of dimensionality, and indeed, strongly so. We contrast our query complexity to that of ball search, a simple and natural algorithm for finding counterfactuals: first query f on x ⋆ and all instances that differ from x ⋆ by a single feature. (By the monotonicity of f , for any feature, it suffices to query f on the instance that differs maximally from x ⋆ on that feature.) Next, query f on the instances that differ by two features, and so on, until a counterfactual is found. This algorithm has query complexity d O(∆ f (x ⋆ )) , an exponentially worse dependence on d than ours. Prior to our work, this was the best known query complexity even just to return a single optimal counterfactual.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Cited by top-tier papers7
- Local vs. Global Interpretability: A Computational Complexity PerspectiveShahaf Bassan, Guy Amir, Guy KatzICML 2024 · 28 citations
- Formal Mechanistic Interpretability: Automated Circuit Discovery with Provable GuaranteesItamar Hadad, Guy Katz, Shahaf BassanICLR 2026 · 10 citations
- Additive Models Explained: A Computational Complexity ApproachShahaf Bassan, Michal Moshkovitz, Guy KatzNeurIPS 2025 · 4 citations
- Robust Explanation Constraints for Neural NetworksMatthew Wicker, Juyeon Heo, Luca Costabello, Adrian WellerICLR 2023 · 3 citations
- Provably Explaining Neural Additive ModelsShahaf Bassan, Yizhak Yisrael Elboher, Tobias Ladner, Volkan Şahin et al.ICLR 2026 · 3 citations
Builds on4
- Robust and Stable Black Box ExplanationsHimabindu Lakkaraju, Nino Arsov, Osbert BastaniICML 2020 · 93 citations
- Born-Again Tree EnsemblesThibaut Vidal, Maximilian SchifferICML 2020 · 62 citations
- Provably efficient, succinct, and precise explanationsGuy Blanc, Jane Lange, Li-Yang TanNeurIPS 2021 · 45 citations
- The query complexity of certificationGuy Blanc, Caleb Koch, Jane Lange, Li-Yang TanSTOC 2022 · 1 citation
Related papers
- Black-Box Methods for Restoring MonotonicityEvangelia Gergatsouli, Brendan Lucier, Christos TzamosICML 2020 · 3 citations
- Near-optimal Active Regression of Single-Index ModelsYi Li, Wai Ming TaiICLR 2025
- Boolean Function Monotonicity Testing Requires (Almost) n1/2 QueriesMark Chen, Xi Chen, Hao Cui, William Pires et al.STOC 2026
- The Adaptive Complexity of Maximizing a Gross Substitutes ValuationRon Kupfer, Sharon Qian, Eric Balkanski, Yaron SingerNeurIPS 2020 · 4 citations
- Monotone ContractionsEleni Batziou, John Fearnley, Spencer Gordon, Ruta Mehta et al.STOC 2025 · 1 citation
