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

Add a "statement use" option #123

Merged
merged 7 commits into from
Sep 1, 2023
Merged

Add a "statement use" option #123

merged 7 commits into from
Sep 1, 2023

Conversation

tirix
Copy link
Collaborator

@tirix tirix commented Aug 27, 2023

As suggested by @GinoGiotto in a comment in #3399, this adds an option to get direct of indirect usage of theorems, given by the list of their labels.

@GinoGiotto
Copy link

That's very nice! Definitely I'll apply it for axiom minimizations (this is useful as well for activities like metamath/set.mm#3431, because I needed to list all theorems using df-clel but not ax-8, and --axiom-use doesn't tell definitions, so it wasn't enough for that).

Thank you so much for this work!

src/main.rs Outdated
c == ',' || (c.is_ascii() && c.is_alphanumeric()) || c == '-' || c == '_' || c == '.'
})
.then_some(())
.ok_or("Expected list of Metamaths labels".to_string())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.ok_or("Expected list of Metamaths labels".to_string())
.ok_or("Expected list of labels".to_string())

I don't think we need to specify this, we don't usually qualify the term elsewhere. We could clarify the grammar in the error message if you think it helps though.

Copy link
Member

@digama0 digama0 Aug 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also a good place to use glob patterns, if we have them (I think david had an implementation in another PR?) (We can do this in a follow up PR if you prefer)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We did not keep the glob patterns in the final solution. I think eventually the best is to first split the project into library/command line tool, and then only include the glob library of choice into the latter. So yes, let's keep that for later.

src/main.rs Outdated Show resolved Hide resolved
@GinoGiotto
Copy link

I executed the command cargo run -- set.mm --stmt-use nfmo,nfmod,nfmod2 and it works, but it prints the output directly on the command line. Can the output be printed in a text file like --axiom-use does?

@tirix
Copy link
Collaborator Author

tirix commented Aug 28, 2023

It works, but it prints the output directly on the command line.

Yes, that's not ideal. How about changing the parameters so that --stmt-use would take two parameters, the file name and the list of labels, like this:

OPTIONS:
    -X, --axiom-use <FILE>            Generate `axiom-use` file
        --stmt-use <FILE> <LABELS>    Outputs statements directly or indirectly using the given list of statements

@GinoGiotto
Copy link

Sounds good, I like it.

One for the file and one for the label list.
@tirix
Copy link
Collaborator Author

tirix commented Aug 28, 2023

I've committed an update which does that.

I could not use the validator function because it would be applied both on the file path and the label list, so I moved it into our own code.

src/main.rs Outdated Show resolved Hide resolved
src/axiom_use.rs Outdated Show resolved Hide resolved
tirix and others added 3 commits August 29, 2023 00:17
Co-authored-by: Mario Carneiro <[email protected]>
Co-authored-by: Mario Carneiro <[email protected]>
@tirix tirix merged commit 7c7ac8c into metamath:main Sep 1, 2023
4 checks passed
@tirix tirix deleted the trace-back branch September 1, 2023 15:10
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.

3 participants