This implements the `termination_by structural` syntax proposed in #3909. I went with `termination_by structural` over, say, `termination_by (config := {method := .structural})` mainly because it was easier to get going (otherwise I’d have to look into how to define recursive parsers, as `Parser.config` depends on `term` and `termination_by` is part of term. But also because I find it more ergonomic and aesthetic as a user. But syntax can still change. The `termination_by?` syntax will no longer force well-founded recursion, and instead the inferred `termination_by structurally` annotation will be shown if structural termination is possible. While I was it, this fixes #4546 the easy way (log errors about but otherwise ignore incomplete `termination_by` sets for mutual recursion). Maybe we get multiple replacements (#4551), but even then this this good behavior. Involves a bit of shuffling around `TerimationHints` (now validated for a clique already by `PreDefinition.main`) and `TerminationArguments` (now lifted out of the `WF` namespace, and a bit simplified). Fixes #3909 --------- Co-authored-by: Richard Kiss <him@richardkiss.com>
60 lines
1.8 KiB
Text
60 lines
1.8 KiB
Text
{"title": "Try this: termination_by (n, m)",
|
|
"kind": "quickfix",
|
|
"isPreferred": true,
|
|
"edit":
|
|
{"documentChanges":
|
|
[{"textDocument":
|
|
{"version": 1, "uri": "file:///terminationBySuggestion.lean"},
|
|
"edits":
|
|
[{"range":
|
|
{"start": {"line": 4, "character": 0},
|
|
"end": {"line": 4, "character": 15}},
|
|
"newText": "termination_by (n, m)"}]}]}}
|
|
{"title": "Try this: termination_by structural n",
|
|
"kind": "quickfix",
|
|
"isPreferred": true,
|
|
"edit":
|
|
{"documentChanges":
|
|
[{"textDocument":
|
|
{"version": 1, "uri": "file:///terminationBySuggestion.lean"},
|
|
"edits":
|
|
[{"range":
|
|
{"start": {"line": 11, "character": 0},
|
|
"end": {"line": 11, "character": 15}},
|
|
"newText": "termination_by structural n"}]}]}}
|
|
{"title": "Try this: termination_by structural x => x",
|
|
"kind": "quickfix",
|
|
"isPreferred": true,
|
|
"edit":
|
|
{"documentChanges":
|
|
[{"textDocument":
|
|
{"version": 1, "uri": "file:///terminationBySuggestion.lean"},
|
|
"edits":
|
|
[{"range":
|
|
{"start": {"line": 17, "character": 0},
|
|
"end": {"line": 17, "character": 15}},
|
|
"newText": "termination_by structural x => x"}]}]}}
|
|
{"title": "Try this: termination_by n",
|
|
"kind": "quickfix",
|
|
"isPreferred": true,
|
|
"edit":
|
|
{"documentChanges":
|
|
[{"textDocument":
|
|
{"version": 1, "uri": "file:///terminationBySuggestion.lean"},
|
|
"edits":
|
|
[{"range":
|
|
{"start": {"line": 24, "character": 0},
|
|
"end": {"line": 24, "character": 15}},
|
|
"newText": "termination_by n"}]}]}}
|
|
{"title": "Try this: termination_by x1 => x1",
|
|
"kind": "quickfix",
|
|
"isPreferred": true,
|
|
"edit":
|
|
{"documentChanges":
|
|
[{"textDocument":
|
|
{"version": 1, "uri": "file:///terminationBySuggestion.lean"},
|
|
"edits":
|
|
[{"range":
|
|
{"start": {"line": 31, "character": 0},
|
|
"end": {"line": 31, "character": 15}},
|
|
"newText": "termination_by x1 => x1"}]}]}}
|