Skip to content

Commit

Permalink
Add parenthesis to TPTP formatting of unary and binary formulas
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachJHansen authored Dec 4, 2024
1 parent 8117e97 commit 4f59103
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/formatting/fol/tptp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,13 @@ impl Precedence for Format<'_, Formula> {
Associativity::Left
}

fn mandatory_parentheses(&self) -> bool {
match self.0 {
Formula::AtomicFormula(_) | Formula::QuantifiedFormula { .. } => false,
Formula::UnaryFormula { .. } | Formula::BinaryFormula { .. } => true,
}
}

fn fmt_operator(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self.0 {
Formula::UnaryFormula { connective, .. } => write!(f, "{}", Format(connective)),
Expand Down Expand Up @@ -615,7 +622,7 @@ mod tests {
.into(),
})
.to_string(),
"p => q => r"
"(p => q) => r"
);
assert_eq!(
Format(&Formula::QuantifiedFormula {
Expand Down Expand Up @@ -692,7 +699,7 @@ mod tests {
}.into()
})
.to_string(),
"![X_i_s: symbol, X_i: $int, Y1_g: general]: (p(f__integer__(X_i)) & q(Y1_g) & t(f__symbolic__(X_i_s)))"
"![X_i_s: symbol, X_i: $int, Y1_g: general]: ((p(f__integer__(X_i)) & q(Y1_g)) & t(f__symbolic__(X_i_s)))"
);
}
}

0 comments on commit 4f59103

Please sign in to comment.