Skip to content
Rainbow docs menu

Reference · The Applied Higher-Order Functions catalogue

rainbow.algorithms.proofs.ahof.counterfactual-cf

The Applied Higher-Order Functions cataloguesrc/rainbow/algorithms/proofs/ahof/counterfactual_cf.clj1 definitions, 4 theorems

AHoF V57 Counterfactual Explanation: explain a model decision by the smallest change to the input that flips the prediction to a desired class. What is defined here is only the BUDGET-FEASIBILITY part of that check: a candidate passes when its change cost (distance from the original input) is within the user's action budget: valid-counterfactual? change-cost budget = decide (change-cost <= budget). Passing this test does not make a candidate a valid counterfactual; validity also needs the prediction to change to the desired class, which is not modelled here (an unchanged input of cost 0 within budget 1 passes even for a constant classifier f(x)=0 with desired class 1). Proved native and axiom-free, as worked instances: cost 1/2 within budget 3/4 passes, cost 1/2 at budget 1/2 passes, the certificate 1/2 <= 3/4, and cost 3/4 over budget 1/2 is rejected. Requires audit/decide-nnrat-at-most, nnrat/at-most, nnrat/decide-at-most-true-sound (all in the D63 checkpoint). Scope (measured by the kernel): this module has 4 worked instances (statements about specific values). None of its theorems is a guarantee about the algorithm for all inputs; `lein verify rainbow.algorithms.proofs.ahof.counterfactual-cf` prints this classification.

cf/valid-counterfactual?

DefinitionSource, line 51

cf/valid-counterfactual? :
  (x₁ x₂ : ℚ≥0)
  → data/Bool

ℚ≥0 = nnrat/NonnegativeRational

cf/within-budget-valid

TheoremWorked exampleNo axiomsSource, line 59

cf/within-budget-valid :
  → ce-fal/elite? 1/2 3/4 = data/true

= = equality/Eq

cf/boundary-valid

TheoremWorked exampleNo axiomsSource, line 65

cf/boundary-valid :
  → ce-fal/elite? 1/2 1/2 = data/true

= = equality/Eq

cf/proximity-certificate

TheoremWorked exampleNo axiomsSource, line 71

cf/proximity-certificate :
  → 1/2 ≤ 3/4

≤ = nnrat/at-most

cf/over-budget-rejected

TheoremWorked exampleNo axiomsSource, line 76

cf/over-budget-rejected :
  → ce-fal/elite? 3/4 1/2 = data/false

= = equality/Eq