File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
tests/lean/grind/experiments Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ open Option
2+
3+ set_option grind.warning false
4+
5+ -- TODO: the following lemmas currently fail, but could be solved with some subset of the following attributes:
6+ -- I haven't added them yet, because the nuclear option of `[grind cases]` is tempting, but a bit scary.
7+
8+ attribute [grind] Option.eq_none_of_isNone
9+ attribute [grind] Option.toArray_eq_empty_iff
10+ attribute [grind] Option.toList_eq_nil_iff
11+
12+ attribute [grind cases] Option
13+
14+ theorem toArray_eq_empty_iff {o : Option α} : o.toArray = #[] ↔ o = none := by
15+ grind
16+
17+ theorem toArray_eq_singleton_iff {o : Option α} : o.toArray = #[a] ↔ o = some a := by
18+ grind
19+
20+ theorem size_toArray_eq_zero_iff {o : Option α} :
21+ o.toArray.size = 0 ↔ o = none := by
22+ grind
23+
24+ theorem toList_eq_nil_iff {o : Option α} : o.toList = [] ↔ o = none := by
25+ grind
26+
27+ theorem toList_eq_singleton_iff {o : Option α} : o.toList = [a] ↔ o = some a := by
28+ grind
29+
30+ theorem length_toList_eq_zero_iff {o : Option α} :
31+ o.toList.length = 0 ↔ o = none := by
32+ grind
33+
34+ attribute [grind] Std.IdempotentOp -- Lots more of these!
35+
36+ example [Max α] [Std.IdempotentOp (α := α) max] {p : α → Bool} {o : Option α} :
37+ max (o.filter p) o = o := by grind
38+
39+ example [Max α] [Std.IdempotentOp (α := α) max] {o : Option α} {p : (a : α) → o = some a → Bool} :
40+ max (o.pfilter p) o = o := by grind
41+
42+ example [Max α] {o o' : Option α} : (max o o').isSome = (o.isSome || o'.isSome) := by grind
43+
44+ example [Max α] {o o' : Option (Option α)} : (max o o').join = max o.join o'.join := by grind
You can’t perform that action at this time.
0 commit comments