This PR adjusts the "try this" widget to be rendered as a widget message under 'Messages', not a separate widget under a 'Suggestions' section. The main benefit of this is that the message of the widget is not duplicated between 'Messages' and 'Suggestions'. Since widget message suggestions were already implemented by @jrr6 for the new hint infrastructure, this PR replaces the old "try this" implementation with the new hint infrastructure. In doing so, the `style?` field of suggestions is deprecated, since the hint infrastructure highlights hints using diff colors, and `style?` also never saw much use downstream. Additionally, since the message and the suggestion are now the same component, the `messageData?` field of suggestions is deprecated as well. Notably, the "Try this:" message string now also contains a newline and indentation to separate the suggestion from the rest of the message more clearly and the `postInfo?` field of the suggestion is now part of the message. Finally, this PR changes the diff colors used by the hint infrastructure to be more color-blindness-friendly (insertions are now blue, not green, and text that remains unchanged is now using the editor foreground color instead of blue). ### Breaking changes Tests that use `#guard_msgs` to test the "Try this:" message may need to be adjusted for the new formatting of the message.
114 lines
2.6 KiB
Text
114 lines
2.6 KiB
Text
module
|
||
reset_grind_attrs%
|
||
|
||
attribute [grind =] List.length_cons
|
||
attribute [grind =] List.getElem?_eq_getElem
|
||
attribute [grind =] List.length_replicate
|
||
attribute [grind =] List.getElem_replicate
|
||
attribute [grind =] List.getElem?_eq_none
|
||
attribute [grind =] List.getElem?_eq_some_iff
|
||
attribute [grind =] getElem!_pos
|
||
|
||
attribute [grind =] Option.map_some Option.map_none
|
||
attribute [grind =] List.getElem?_map
|
||
attribute [grind =] List.getElem?_replicate
|
||
|
||
attribute [grind =] List.getLast?_eq_some_iff
|
||
attribute [grind] List.mem_concat_self
|
||
|
||
attribute [grind =] List.getElem_cons_zero in
|
||
attribute [grind =] List.getElem?_cons_zero in
|
||
|
||
/--
|
||
info: Try this:
|
||
grind only [= List.getElem?_eq_none, = List.getElem?_eq_getElem, = List.getElem?_replicate]
|
||
-/
|
||
#guard_msgs (info) in
|
||
theorem getElem?_replicate' : (List.replicate n a)[m]? = if m < n then some a else none := by
|
||
grind?
|
||
|
||
/--
|
||
info: Try this:
|
||
grind only [= List.length_cons]
|
||
-/
|
||
#guard_msgs (info) in
|
||
example : 0 < (x :: t).length := by
|
||
grind?
|
||
|
||
attribute [grind ext] List.ext_getElem?
|
||
/--
|
||
info: Try this:
|
||
grind only [= List.length_replicate, = List.getElem?_eq_none, = List.getElem?_eq_getElem,
|
||
= List.getElem?_eq_some_iff, = Option.map_some, = Option.map_none, = List.getElem?_replicate,
|
||
= List.getElem_replicate, = List.getElem?_map]
|
||
-/
|
||
#guard_msgs (info) in
|
||
theorem map_replicate' : (List.replicate n a).map f = List.replicate n (f a) := by
|
||
grind?
|
||
|
||
/--
|
||
info: Try this:
|
||
grind only [List.mem_concat_self, = List.getLast?_eq_some_iff]
|
||
-/
|
||
#guard_msgs (info) in
|
||
theorem mem_of_getLast?_eq_some' {xs : List α} {a : α} (h : xs.getLast? = some a) : a ∈ xs := by
|
||
grind?
|
||
|
||
@[expose] public def f : Nat → Nat
|
||
| 0 => 1
|
||
| _ => 2
|
||
|
||
/--
|
||
info: Try this:
|
||
grind only
|
||
-/
|
||
#guard_msgs (info) in
|
||
example : x = 0 → f x = 1 := by
|
||
unfold f
|
||
grind? -- should not include match equations
|
||
|
||
attribute [grind] f
|
||
|
||
/--
|
||
info: Try this:
|
||
grind only [f]
|
||
-/
|
||
#guard_msgs (info) in
|
||
example : x = 0 → f x = 1 := by
|
||
grind? [f]
|
||
|
||
opaque g : Nat → Nat
|
||
|
||
theorem gthm : g (g x) = g x := sorry
|
||
|
||
grind_pattern gthm => g (g x)
|
||
|
||
/--
|
||
info: Try this:
|
||
grind only [usr gthm]
|
||
-/
|
||
#guard_msgs (info) in
|
||
example : g (g (g x)) = g x := by
|
||
grind?
|
||
|
||
/--
|
||
error: `And` is marked as a built-in case-split for `grind` and cannot be erased
|
||
-/
|
||
#guard_msgs (error) in
|
||
attribute [-grind] And
|
||
|
||
/--
|
||
error: `And` is marked as a built-in case-split for `grind` and cannot be erased
|
||
-/
|
||
#guard_msgs (error) in
|
||
example : p ∧ q → p := by
|
||
grind [-And]
|
||
|
||
example : (List.replicate n a)[m]? = if m < n then some a else none := by
|
||
grind?
|
||
|
||
reset_grind_attrs%
|
||
|
||
example : (List.replicate n a)[m]? = if m < n then some a else none := by
|
||
fail_if_success grind?
|
||
sorry
|