lean4-htt/tests/lean/grind/experiments/option.lean
Kim Morrison eccc472e8d
chore: remove set_option grind.warning false (#8714)
This PR removes the now unnecessary `set_option grind.warning false`
statements, now that the warning is disabled by default.
2025-06-11 05:09:19 +00:00

42 lines
1.5 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

open Option
-- TODO: the following lemmas currently fail, but could be solved with some subset of the following attributes:
-- I haven't added them yet, because the nuclear option of `[grind cases]` is tempting, but a bit scary.
attribute [grind] Option.eq_none_of_isNone
attribute [grind] Option.toArray_eq_empty_iff
attribute [grind] Option.toList_eq_nil_iff
attribute [grind cases] Option
theorem toArray_eq_empty_iff {o : Option α} : o.toArray = #[] ↔ o = none := by
grind
theorem toArray_eq_singleton_iff {o : Option α} : o.toArray = #[a] ↔ o = some a := by
grind
theorem size_toArray_eq_zero_iff {o : Option α} :
o.toArray.size = 0 ↔ o = none := by
grind
theorem toList_eq_nil_iff {o : Option α} : o.toList = [] ↔ o = none := by
grind
theorem toList_eq_singleton_iff {o : Option α} : o.toList = [a] ↔ o = some a := by
grind
theorem length_toList_eq_zero_iff {o : Option α} :
o.toList.length = 0 ↔ o = none := by
grind
attribute [grind] Std.IdempotentOp -- Lots more of these!
example [Max α] [Std.IdempotentOp (α := α) max] {p : α → Bool} {o : Option α} :
max (o.filter p) o = o := by grind
example [Max α] [Std.IdempotentOp (α := α) max] {o : Option α} {p : (a : α) → o = some a → Bool} :
max (o.pfilter p) o = o := by grind
example [Max α] {o o' : Option α} : (max o o').isSome = (o.isSome || o'.isSome) := by grind
example [Max α] {o o' : Option (Option α)} : (max o o').join = max o.join o'.join := by grind