2020-01-24 18:43:42 +01:00
|
|
|
// Operators
|
|
|
|
|
|
|
|
pub enum BinaryOperator
|
|
|
|
{
|
|
|
|
Addition,
|
|
|
|
Subtraction,
|
|
|
|
Multiplication,
|
|
|
|
Division,
|
|
|
|
Modulo,
|
|
|
|
Exponentiation,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub enum ComparisonOperator
|
|
|
|
{
|
|
|
|
Greater,
|
|
|
|
Less,
|
|
|
|
LessOrEqual,
|
|
|
|
GreaterOrEqual,
|
|
|
|
NotEqual,
|
|
|
|
Equal,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub enum UnaryOperator
|
|
|
|
{
|
|
|
|
AbsoluteValue,
|
|
|
|
Negation,
|
|
|
|
}
|
|
|
|
|
|
|
|
// Primitives
|
|
|
|
|
|
|
|
pub struct FunctionDeclaration
|
|
|
|
{
|
|
|
|
pub name: String,
|
|
|
|
pub arity: usize,
|
|
|
|
}
|
|
|
|
|
2019-11-01 22:00:17 +01:00
|
|
|
pub struct PredicateDeclaration
|
|
|
|
{
|
|
|
|
pub name: String,
|
|
|
|
pub arity: usize,
|
|
|
|
}
|
|
|
|
|
2020-01-24 18:43:42 +01:00
|
|
|
pub struct VariableDeclaration
|
2019-11-01 22:00:17 +01:00
|
|
|
{
|
2020-01-24 18:43:42 +01:00
|
|
|
pub name: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
// Terms
|
|
|
|
|
|
|
|
pub struct BinaryOperation
|
|
|
|
{
|
|
|
|
pub operator: BinaryOperator,
|
|
|
|
pub left: Box<Term>,
|
|
|
|
pub right: Box<Term>,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct Function
|
|
|
|
{
|
|
|
|
pub declaration: std::rc::Rc<FunctionDeclaration>,
|
|
|
|
pub arguments: Vec<Box<Term>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub enum SpecialInteger
|
|
|
|
{
|
|
|
|
Infimum,
|
|
|
|
Supremum,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct UnaryOperation
|
|
|
|
{
|
|
|
|
pub operator: UnaryOperator,
|
|
|
|
pub argument: Box<Term>,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct Variable
|
|
|
|
{
|
|
|
|
pub declaration: std::rc::Rc<VariableDeclaration>,
|
|
|
|
}
|
|
|
|
|
|
|
|
// Formulas
|
|
|
|
|
|
|
|
pub struct Biconditional
|
|
|
|
{
|
|
|
|
pub left: Box<Formula>,
|
|
|
|
pub right: Box<Formula>,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct Comparison
|
|
|
|
{
|
|
|
|
pub operator: ComparisonOperator,
|
|
|
|
pub left: Box<Term>,
|
|
|
|
pub right: Box<Term>,
|
2019-11-01 22:00:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct Exists
|
|
|
|
{
|
2020-01-24 18:43:42 +01:00
|
|
|
pub parameters: Vec<std::rc::Rc<VariableDeclaration>>,
|
2019-11-01 22:00:17 +01:00
|
|
|
pub argument: Box<Formula>,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct ForAll
|
|
|
|
{
|
2020-01-24 18:43:42 +01:00
|
|
|
pub parameters: Vec<std::rc::Rc<VariableDeclaration>>,
|
2019-11-01 22:00:17 +01:00
|
|
|
pub argument: Box<Formula>,
|
|
|
|
}
|
|
|
|
|
2020-01-24 18:43:42 +01:00
|
|
|
pub struct Implies
|
2019-11-01 22:00:17 +01:00
|
|
|
{
|
2020-01-24 18:43:42 +01:00
|
|
|
pub antecedent: Box<Formula>,
|
|
|
|
pub implication: Box<Formula>,
|
2019-11-01 22:00:17 +01:00
|
|
|
}
|
|
|
|
|
2020-01-24 18:43:42 +01:00
|
|
|
pub struct Predicate
|
2019-11-01 22:00:17 +01:00
|
|
|
{
|
2020-01-24 18:43:42 +01:00
|
|
|
pub declaration: std::rc::Rc<PredicateDeclaration>,
|
|
|
|
pub arguments: Vec<Box<Term>>,
|
2019-11-01 22:00:17 +01:00
|
|
|
}
|
|
|
|
|
2020-01-24 18:43:42 +01:00
|
|
|
// Variants
|
2019-11-01 22:00:17 +01:00
|
|
|
|
|
|
|
pub enum Term
|
|
|
|
{
|
2020-01-24 18:43:42 +01:00
|
|
|
BinaryOperation(BinaryOperation),
|
|
|
|
Boolean(bool),
|
|
|
|
Function(Function),
|
|
|
|
Integer(i32),
|
|
|
|
SpecialInteger(SpecialInteger),
|
2019-11-01 22:00:17 +01:00
|
|
|
String(String),
|
2020-01-24 18:43:42 +01:00
|
|
|
Symbolic(String),
|
|
|
|
UnaryOperation(UnaryOperation),
|
|
|
|
Variable(Variable),
|
2019-11-01 22:00:17 +01:00
|
|
|
}
|
2020-01-24 18:43:42 +01:00
|
|
|
|
|
|
|
pub type Terms = Vec<Box<Term>>;
|
|
|
|
|
|
|
|
pub enum Formula
|
|
|
|
{
|
|
|
|
And(Formulas),
|
|
|
|
Biconditional(Biconditional),
|
|
|
|
Boolean(bool),
|
|
|
|
Comparison(Comparison),
|
|
|
|
Exists(Exists),
|
|
|
|
ForAll(ForAll),
|
|
|
|
Implies(Implies),
|
|
|
|
Not(Box<Formula>),
|
|
|
|
Or(Formulas),
|
|
|
|
Predicate(Predicate),
|
|
|
|
}
|
|
|
|
|
|
|
|
pub type Formulas = Vec<Box<Formula>>;
|