Skip to content

Commit

Permalink
feat(data/finset/fold): add lemma fold_max_add (#15257)
Browse files Browse the repository at this point in the history
The lemma shows that adding inside or outside a "max-fold" amounts to the same.  It is the folded version of docs#max_add_add_right.
  • Loading branch information
adomani committed Jul 16, 2022
1 parent 624716b commit 4538aeb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/data/finset/fold.lean
Expand Up @@ -230,6 +230,11 @@ end
lemma lt_fold_max : c < s.fold max b f ↔ (c < b ∨ ∃ x∈s, c < f x) :=
fold_op_rel_iff_or $ λ x y z, lt_max_iff

lemma fold_max_add [has_add β] [covariant_class β β (function.swap (+)) (≤)]
(n : with_bot β) (s : finset α) :
s.fold max ⊥ (λ (x : α), ↑(f x) + n) = s.fold max ⊥ (coe ∘ f) + n :=
by { classical, apply s.induction_on; simp [max_add_add_right] {contextual := tt} }

end order

end fold
Expand Down

0 comments on commit 4538aeb

Please sign in to comment.