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

Zach/completion #73

Closed
wants to merge 5 commits into from
Closed
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
23 changes: 23 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ license = "MIT"
[dependencies]
anyhow = "1"
clap = { version = "4", features = ["derive"] }
indexmap = "2"
lazy_static = "1"
pest = "2"
pest_derive = "2"
Expand Down
1 change: 1 addition & 0 deletions src/command_line/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub enum Command {
pub enum Translation {
Gamma,
TauStar,
Completion,
}

#[cfg(test)]
Expand Down
13 changes: 12 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use {
crate::{
command_line::{Arguments, Command, Translation},
syntax_tree::{asp, fol},
translating::tau_star::tau_star,
translating::{completion::completion, tau_star::tau_star},
},
anyhow::{Context, Result},
clap::Parser as _,
Expand Down Expand Up @@ -44,6 +44,17 @@ fn main() -> Result<()> {

print!("{theory}")
}

Translation::Completion => {
let theory: fol::Theory = content
.parse()
.with_context(|| format!("could not parse file `{}`", input.display()))?;

let theory =
completion(&theory).with_context(|| format!("not a completable theory"))?;

print!("{theory}")
}
}

Ok(())
Expand Down
15 changes: 9 additions & 6 deletions src/simplifying/fol/ht.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use crate::{
syntax_tree::fol::{AtomicFormula, BinaryConnective, Formula},
};

pub fn simplify(formula: Formula) -> Formula {
formula.apply(&mut simplify_outer)
pub fn basic_simplify(formula: Formula) -> Formula {
formula.apply(&mut basic_simplify_outer)
}

pub fn simplify_outer(formula: Formula) -> Formula {
pub fn basic_simplify_outer(formula: Formula) -> Formula {
// TODO: Split simplifications into multiple functions?

match formula.unbox() {
Expand Down Expand Up @@ -93,7 +93,7 @@ pub fn simplify_outer(formula: Formula) -> Formula {

#[cfg(test)]
mod tests {
use super::{simplify, simplify_outer};
use super::{basic_simplify, basic_simplify_outer};

#[test]
fn test_simplify() {
Expand All @@ -111,7 +111,10 @@ mod tests {
("#true and #true and a", "a"),
("#true and (#true and a)", "a"),
] {
assert_eq!(simplify(src.parse().unwrap()), target.parse().unwrap())
assert_eq!(
basic_simplify(src.parse().unwrap()),
target.parse().unwrap()
)
}
}

Expand All @@ -132,7 +135,7 @@ mod tests {
("(#true and #true) and a", "(#true and #true) and a"),
] {
assert_eq!(
simplify_outer(src.parse().unwrap()),
basic_simplify_outer(src.parse().unwrap()),
target.parse().unwrap()
)
}
Expand Down
Loading
Loading