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

Implementation of Ordered Completion #175

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
implement coinjoin order atoms
janheuer committed Dec 5, 2024
commit 6a184f81103ebe17bb8dff37c966068466ee3150
40 changes: 39 additions & 1 deletion src/translating/ordered_completion.rs
Original file line number Diff line number Diff line change
@@ -58,11 +58,49 @@ pub fn ordered_completion(theory: fol::Theory) -> Option<fol::Theory> {
Some(fol::Theory { formulas })
}

fn create_order_atom(p: fol::Atom, q: fol::Atom) -> fol::Atom {
fol::Atom {
predicate_symbol: format!("less_{}_{}", p.predicate_symbol, q.predicate_symbol),
terms: p.terms.into_iter().chain(q.terms).collect(),
}
}

fn conjoin_order_atoms(formula: fol::Formula, head_atom: fol::Atom) -> fol::Formula {
// replaces all positive atoms q(zs) in formula (i.e. all q(zs) not in the scope of any negation) by
// q(zs) and less_p_q(xs, zs)
// where p(xs) is head_atom
todo!()
match formula {
fol::Formula::AtomicFormula(fol::AtomicFormula::Atom(ref q)) => {
let order_atom = create_order_atom(q.clone(), head_atom);

fol::Formula::BinaryFormula {
connective: fol::BinaryConnective::Conjunction,
lhs: formula.into(),
rhs: fol::Formula::AtomicFormula(fol::AtomicFormula::Atom(order_atom)).into(),
}
}
fol::Formula::AtomicFormula(_) => formula,
fol::Formula::UnaryFormula {
connective: fol::UnaryConnective::Negation,
..
} => formula,
fol::Formula::BinaryFormula {
connective,
lhs,
rhs,
} => fol::Formula::BinaryFormula {
connective,
lhs: conjoin_order_atoms(*lhs, head_atom.clone()).into(),
rhs: conjoin_order_atoms(*rhs, head_atom).into(),
},
fol::Formula::QuantifiedFormula {
quantification,
formula,
} => fol::Formula::QuantifiedFormula {
quantification,
formula: conjoin_order_atoms(*formula, head_atom).into(),
},
}
}

#[cfg(test)]