2020-05-22 02:25:00 +02:00
|
|
|
pub(crate) fn term_contains_variable(term: &crate::Term,
|
|
|
|
variable_declaration: &crate::VariableDeclaration)
|
2020-05-19 12:56:46 +02:00
|
|
|
-> bool
|
|
|
|
{
|
2020-05-22 02:25:00 +02:00
|
|
|
use crate::Term;
|
2020-05-19 12:56:46 +02:00
|
|
|
|
|
|
|
match term
|
|
|
|
{
|
|
|
|
Term::BinaryOperation(binary_operation) =>
|
|
|
|
term_contains_variable(&binary_operation.left, variable_declaration)
|
|
|
|
|| term_contains_variable(&binary_operation.right, variable_declaration),
|
|
|
|
Term::Boolean(_)
|
|
|
|
| Term::Function(_)
|
|
|
|
| Term::Integer(_)
|
|
|
|
| Term::SpecialInteger(_)
|
|
|
|
| Term::String(_) => false,
|
|
|
|
Term::UnaryOperation(unary_operation) =>
|
|
|
|
term_contains_variable(&unary_operation.argument, variable_declaration),
|
|
|
|
Term::Variable(variable) => *variable.declaration == *variable_declaration,
|
|
|
|
}
|
|
|
|
}
|