Skip to content
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: indicate replacements in synport output #198

Merged
merged 2 commits into from
Nov 3, 2022
Merged

Conversation

digama0
Copy link
Member

@digama0 digama0 commented Nov 2, 2022

Definitions that align are now printed like so:

#print Function.injective_id /-
theorem injective_id : Injective (@id α) := fun a₁ a₂ h => h
-/

The comment is the output mathport would have produced, if the definition Function.injective_id had not already existed in the environment. This is intended to make it easier to survey an already ported file and quickly identify any new definitions that have been introduced.

@gebner
Copy link
Member

gebner commented Nov 2, 2022

Is there an easy way to move the newline after the comment?

+#print PosPart /-
 /-- The positive part of an element admiting a decomposition into positive and negative parts.
 -/
 class PosPart (α : Type _) where
   Pos : α → α

+-/
+#print NegPart /-
 /-- The negative part of an element admiting a decomposition into positive and negative parts.
 -/
 class NegPart (α : Type _) where
   neg : α → α

+-/

@gebner
Copy link
Member

gebner commented Nov 2, 2022

We also get lots of parenthesization errors now, not sure which commit introduced them.

@digama0
Copy link
Member Author

digama0 commented Nov 2, 2022

No, at least not if you mean fixing some \n in a string literal. We could add an extra newline but the trailing -/ would still be two lines away from the end of the command. To fix it properly we would need to either consume a newline from the string (which I suppose isn't crazy, since we can be fairly certain it has been emitted), or buffer command strings in a more structured way and use intersperse to avoid an extra trailing newline.

@digama0
Copy link
Member Author

digama0 commented Nov 2, 2022

The parenthesization errors look like an uncaught issue from the last bump. Mathport is generating the following for rw [<- foo]:

(Tactic.rwSeq "rw" [] (Tactic.rwRuleSeq "[" [(Tactic.rwRule ["←"] `bind_map_eq_seq)] "]") [])

but lean now wants it to be:

(Tactic.rwSeq "rw" [] (Tactic.rwRuleSeq "[" [(Tactic.rwRule [(patternIgnore (token.«← » "←"))] `foo)] "]") [])

Are these additional nodes intentional? It looks like it will cause a lot of problems since I'm sure there are many other similar instances.

@gebner
Copy link
Member

gebner commented Nov 2, 2022

Oh yes, they are intentional. But they show up in the syntax definition, like group, etc. They tell the syntax pattern matching compiler to ignore that subterm. leanprover/lean4#1744 (comment)

@digama0
Copy link
Member Author

digama0 commented Nov 2, 2022

The patternIgnore part looks unfortunate to me. Ideally the pattern match compiler would know that the original parser has a patternIgnore in it and so the runtime syntax wouldn't need it. In any case, I fixed the issue with rwRule and it fixed all the errors in core, although I haven't checked mathlib. I also added the aforementioned hack to get them printing like so instead:

+#print PosPart /-
 /-- The positive part of an element admiting a decomposition into positive and negative parts.
 -/
 class PosPart (α : Type _) where
   Pos : α → α
+-/

+#print NegPart /-
 /-- The negative part of an element admiting a decomposition into positive and negative parts.
 -/
 class NegPart (α : Type _) where
   neg : α → α
+-/

I can also take off another newline if you want, and have the -/ at the end of the last line of the command, but I thought this version would be more easily copy-paste-able.

@digama0 digama0 merged commit 21d45f0 into master Nov 3, 2022
@digama0 digama0 deleted the replacements branch November 3, 2022 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants