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.
75 lines
2 KiB
Text
75 lines
2 KiB
Text
module
|
|
|
|
public axiom P : Nat → Prop
|
|
public axiom P.intro : P n
|
|
|
|
public inductive AckFuel : (n m : Nat) → Type where
|
|
| step1 : AckFuel 0 m
|
|
| step2 : AckFuel n 1 → AckFuel (n + 1) 0
|
|
| step3 : (∀ m', P m' → AckFuel n m') → AckFuel (n + 1) m → AckFuel (n+1) (m + 1)
|
|
|
|
namespace Test1
|
|
/--
|
|
info: Try this:
|
|
termination_by structural x _ x => x
|
|
-/
|
|
#guard_msgs in
|
|
public def ackermann_fuel : (n m : Nat) → (fuel : AckFuel n m) → Nat
|
|
| 0, m, .step1 => m+1
|
|
| n + 1, 0, .step2 f => ackermann_fuel n 1 f
|
|
| n + 1, m + 1, .step3 f1 f2 =>
|
|
ackermann_fuel n (ackermann_fuel (n + 1) m f2) (f1 _ (by exact P.intro))
|
|
termination_by?
|
|
end Test1
|
|
|
|
namespace Test2
|
|
/--
|
|
info: Try this:
|
|
termination_by structural x _ x => x
|
|
-/
|
|
#guard_msgs in
|
|
public def ackermann_fuel : (n m : Nat) → (fuel : AckFuel n m) → Nat
|
|
| 0, m, .step1 => m+1
|
|
| n + 1, 0, .step2 f => ackermann_fuel n 1 f
|
|
| n + 1, m + 1, .step3 f1 f2 =>
|
|
ackermann_fuel n (ackermann_fuel (n + 1) m f2) (f1 _ (by as_aux_lemma => exact P.intro))
|
|
termination_by?
|
|
end Test2
|
|
|
|
namespace Test3
|
|
/--
|
|
info: Try this:
|
|
termination_by structural x _ x => x
|
|
-/
|
|
#guard_msgs in
|
|
@[expose] public def ackermann_fuel : (n m : Nat) → (fuel : AckFuel n m) → Nat
|
|
| 0, m, .step1 => m+1
|
|
| n + 1, 0, .step2 f => ackermann_fuel n 1 f
|
|
| n + 1, m + 1, .step3 f1 f2 =>
|
|
ackermann_fuel n (ackermann_fuel (n + 1) m f2) (f1 _ (by exact P.intro))
|
|
termination_by?
|
|
end Test3
|
|
|
|
namespace Test4
|
|
|
|
-- This checks that when unfolding abstracted proofs, we do not unfold function calls
|
|
-- that were actually there, like the one to `Function.cons` below
|
|
|
|
/--
|
|
error: failed to infer structural recursion:
|
|
Cannot use parameter #3:
|
|
unexpected occurrence of recursive application
|
|
ackermann_fuel
|
|
-/
|
|
#guard_msgs in
|
|
public def ackermann_fuel : (n m : Nat) → (fuel : AckFuel n m) → Nat
|
|
| 0, m, .step1 => m+1
|
|
| n + 1, 0, .step2 f => ackermann_fuel n 1 f
|
|
| n + 1, m + 1, .step3 f1 f2 =>
|
|
Function.const _
|
|
( ackermann_fuel n (ackermann_fuel (n + 1) m f2) (f1 _ (by exact P.intro))
|
|
)
|
|
ackermann_fuel
|
|
termination_by structural _ _ fuel => fuel
|
|
|
|
end Test4
|