Lean4
/-- Adds a term to a dfinsupp, making a dfinsupp indexed by an `Option`.
This is the dfinsupp version of `Option.rec`. -/
def extendWith [∀ i, Zero (α i)] (a : α none) (f : Π₀ i, α (some i)) : Π₀ i, α i
where
toFun := fun i ↦
match i with
| none => a
| some _ => f _
support' :=
f.support'.map fun s =>
⟨none ::ₘ Multiset.map some s.1, fun i =>
Option.rec (Or.inl <| Multiset.mem_cons_self _ _)
(fun i => (s.prop i).imp_left fun h => Multiset.mem_cons_of_mem <| Multiset.mem_map_of_mem _ h) i⟩