Skip to content

Commit 5cb41d9

Browse files
committed
add open test cases
1 parent f5c598c commit 5cb41d9

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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

0 commit comments

Comments
 (0)