-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: progress with a term #281
base: main
Are you sure you want to change the base?
Conversation
`progress with X` where X can now be a full term, e.g. `X := (@SomeSpec.XYZ T U)`. Signed-off-by: Raito Bezarius <[email protected]>
4dcfcd3
to
f078764
Compare
@sonmarcho I think this is almost ready, there might be still some vague TODOs, but it feels feature-complete, I will take it for a walk and try to come up with proper interesting unit tests. The case:
fails because Lean complains about inability to synthesize the placeholder, I wonder if I should try to fix it in the code by modifying the calls to synthesization and allow failure and create for each failure a new metavar and leave it as a new goal to be assigned by the user (which I feel like is the solution to fix that usecase). |
We might do something like this in the future. I don't see the point of doing this for regular function calls, because then you should always call let x <- if b then 0 else 1 -- We can't use a lemma here
let y <- f x |
-- Try the theorems one by one | ||
for pspec in pspecs do | ||
if ← tryLookupApply keep ids splitPost asmTac fExpr "pspec theorem" pspec then return pspec | ||
-- TODO: convert pspec into an Expr. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What it this TODO?
@@ -219,7 +209,7 @@ def getFirstArg (args : Array Expr) : Option Expr := do | |||
Return true if it succeeded. -/ | |||
def tryLookupApply (keep : Option Name) (ids : Array (Option Name)) (splitPost : Bool) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should rename this function to tryApply
, because it doesn't perform a lookup anymore.
Also, it might make sense to move the match over the option (and the comments printed in the trace are not valid anymore I believe).
-- Either, it's a local declaration or a theorem, either it's a term | ||
-- for which we need to find a declaration | ||
|
||
if id.isIdent then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we really need this case disjunction. Shouldn't it be performed by Lean's elaboration (i.e., isn't the else
branch enough)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, if I do that, something like:
set_option trace.Progress true in
example {x: U32}
(f : Result U32 → Result Unit)
(h : ∀ (x: U32), ∀ (y: U32), f (x + y) = .ok ()):
f (.ok x) = ok () := by
have : ∀ x, f x = .ok () := by sorry
progress with this
won't work because this
elaborated := sorryAx ?m.something true
and the metavariable will create an obscure failure of progress here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(tbh, the current code does not work neither, it fails by not finding this
in the context)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, this is good to know (and worth commenting in the code ;) )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this be a blocker though for the PR? I'm trying to make this work but I'm just diving into how the whole thing is supposed to work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant is that the fact that we need the case disjunction is good to know and should be documented. But of course, we need to make the elaboration work, generally speaking.
stxArgs := stxArgs.setArg 1 withArg | ||
let tac := mkNode `Progress.progress #[mkAtom "progress", stxArgs] | ||
-- if stats.usedTheorem.isInaccesisble then | ||
-- logInfo "{...} is inaccessible, if you want to actually use the suggestion, please use `rename_i ...`" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove all commented code (note however that printing such a comment would be useful, if it is possible).
@@ -268,17 +258,17 @@ def progressAsmsOrLookupTheorem (keep : Option Name) (withTh : Option TheoremOrL | |||
match withTh with | |||
| some th => do | |||
match ← progressWith fExpr th keep ids splitPost asmTac with | |||
| .Ok => return th | |||
| .Ok => return (← exprToSyntax th) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I'm not so sure this is the right way to transform an expression to syntax for progress?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it generate spurious syntax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, just dump a metavariable I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand in which situations it dumps a metavariable: could you clarify a bit?
But if exprToSyntax
doesn't work there is likely a simple way of getting the name of the theorem and transforming it to syntax.
progress with X
where X can now be a full term, e.g.X := (@SomeSpec.XYZ T U)
.TODO:
as
and some failuresSigned-off-by: Ryan Lahfa [email protected]