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 minimizer functionality #156

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions metamath-knife/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ edition = "2021"

[dependencies]
clap = "2.33"
itertools = "0.12.0"
rayon = "1.8.1"
simple_logger = "1.13"
annotate-snippets = "0.9"
metamath-rs = { path = "../metamath-rs" }
Expand Down
15 changes: 14 additions & 1 deletion metamath-knife/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ use std::mem;
use std::str::FromStr;
use std::sync::Arc;

mod minimizer;
use minimizer::minimize;

fn positive_integer(val: String) -> Result<(), String> {
u32::from_str(&val).map(|_| ()).map_err(|e| format!("{e}"))
}
Expand Down Expand Up @@ -53,6 +56,7 @@ fn main() {
(@arg repeat: --repeat "Demonstrates incremental verifier")
(@arg jobs: -j --jobs +takes_value validator(positive_integer)
"Number of threads to use for verification")
(@arg minimize: -M --minimize [LABEL] ... "Attempts to minimize the given theorem")
(@arg export: -e --export [LABEL] ... "Outputs a proof file")
(@arg biblio: --biblio [FILE] ... "Supplies a bibliography file for verify-markup\n\
Can be used one or two times; the second is for exthtml processing")
Expand Down Expand Up @@ -82,7 +86,8 @@ fn main() {
|| matches.is_present("verify_parse_stmt")
|| matches.is_present("export_grammar_dot")
|| matches.is_present("dump_grammar")
|| matches.is_present("dump_formula"),
|| matches.is_present("dump_formula")
|| matches.is_present("minimize"),
jobs: usize::from_str(matches.value_of("jobs").unwrap_or("1"))
.expect("validator should check this"),
};
Expand Down Expand Up @@ -245,6 +250,14 @@ fn main() {
db.print_typesetting();
}

if let Some(exps) = matches.values_of_lossy("minimize") {
db.stmt_parse_pass();
db.verify_usage_pass();
for label in exps {
minimize(&db, &label);
}
}

if let Some(exps) = matches.values_of_lossy("export") {
db.scope_pass();
for file in exps {
Expand Down
Loading
Loading