Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
// Operators
|
|
|
|
|
2020-02-25 19:34:59 +01:00
|
|
|
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
pub enum BinaryOperator
|
|
|
|
{
|
|
|
|
Add,
|
|
|
|
Subtract,
|
|
|
|
Multiply,
|
|
|
|
Divide,
|
|
|
|
Modulo,
|
|
|
|
Exponentiate,
|
|
|
|
}
|
|
|
|
|
2020-02-25 19:34:59 +01:00
|
|
|
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
pub enum ComparisonOperator
|
|
|
|
{
|
|
|
|
Greater,
|
|
|
|
Less,
|
|
|
|
LessOrEqual,
|
|
|
|
GreaterOrEqual,
|
|
|
|
NotEqual,
|
|
|
|
Equal,
|
|
|
|
}
|
|
|
|
|
2020-02-25 19:34:59 +01:00
|
|
|
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
pub enum UnaryOperator
|
|
|
|
{
|
|
|
|
AbsoluteValue,
|
|
|
|
Negative,
|
|
|
|
}
|
|
|
|
|
2020-03-14 02:11:33 +01:00
|
|
|
// ImplicationDirection
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
|
|
|
pub enum ImplicationDirection
|
|
|
|
{
|
|
|
|
LeftToRight,
|
|
|
|
RightToLeft,
|
|
|
|
}
|
|
|
|
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
// Primitives
|
|
|
|
|
|
|
|
#[derive(Eq, Hash, Ord, PartialEq, PartialOrd)]
|
|
|
|
pub struct FunctionDeclaration
|
|
|
|
{
|
|
|
|
pub name: String,
|
|
|
|
pub arity: usize,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl FunctionDeclaration
|
|
|
|
{
|
|
|
|
pub fn new(name: String, arity: usize) -> Self
|
|
|
|
{
|
|
|
|
Self
|
|
|
|
{
|
|
|
|
name,
|
|
|
|
arity,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub type FunctionDeclarations = std::collections::BTreeSet<std::rc::Rc<FunctionDeclaration>>;
|
|
|
|
|
|
|
|
#[derive(Eq, Hash, Ord, PartialEq, PartialOrd)]
|
|
|
|
pub struct PredicateDeclaration
|
|
|
|
{
|
|
|
|
pub name: String,
|
|
|
|
pub arity: usize,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PredicateDeclaration
|
|
|
|
{
|
|
|
|
pub fn new(name: String, arity: usize) -> Self
|
|
|
|
{
|
|
|
|
Self
|
|
|
|
{
|
|
|
|
name,
|
|
|
|
arity,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub type PredicateDeclarations = std::collections::BTreeSet<std::rc::Rc<PredicateDeclaration>>;
|
|
|
|
|
|
|
|
pub struct VariableDeclaration
|
|
|
|
{
|
|
|
|
pub name: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::cmp::PartialEq for VariableDeclaration
|
|
|
|
{
|
|
|
|
#[inline(always)]
|
|
|
|
fn eq(&self, other: &VariableDeclaration) -> bool
|
|
|
|
{
|
|
|
|
let l = self as *const VariableDeclaration;
|
|
|
|
let r = other as *const VariableDeclaration;
|
|
|
|
|
|
|
|
l.eq(&r)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::cmp::Eq for VariableDeclaration
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::cmp::PartialOrd for VariableDeclaration
|
|
|
|
{
|
|
|
|
#[inline(always)]
|
|
|
|
fn partial_cmp(&self, other: &VariableDeclaration) -> Option<std::cmp::Ordering>
|
|
|
|
{
|
|
|
|
let l = self as *const VariableDeclaration;
|
|
|
|
let r = other as *const VariableDeclaration;
|
|
|
|
|
|
|
|
l.partial_cmp(&r)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::cmp::Ord for VariableDeclaration
|
|
|
|
{
|
|
|
|
#[inline(always)]
|
|
|
|
fn cmp(&self, other: &VariableDeclaration) -> std::cmp::Ordering
|
|
|
|
{
|
|
|
|
let l = self as *const VariableDeclaration;
|
|
|
|
let r = other as *const VariableDeclaration;
|
|
|
|
|
|
|
|
l.cmp(&r)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-25 19:34:59 +01:00
|
|
|
impl std::hash::Hash for VariableDeclaration
|
|
|
|
{
|
|
|
|
#[inline(always)]
|
|
|
|
fn hash<H: std::hash::Hasher>(&self, state: &mut H)
|
|
|
|
{
|
|
|
|
let p = self as *const VariableDeclaration;
|
|
|
|
|
|
|
|
p.hash(state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
impl VariableDeclaration
|
|
|
|
{
|
|
|
|
pub fn new(name: String) -> Self
|
|
|
|
{
|
|
|
|
Self
|
|
|
|
{
|
|
|
|
name,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub type VariableDeclarations = Vec<std::rc::Rc<VariableDeclaration>>;
|
|
|
|
|
|
|
|
// Terms
|
|
|
|
|
2020-02-25 19:34:59 +01:00
|
|
|
#[derive(Eq, Hash, Ord, PartialEq, PartialOrd)]
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
pub struct BinaryOperation
|
|
|
|
{
|
|
|
|
pub operator: BinaryOperator,
|
|
|
|
pub left: Box<Term>,
|
|
|
|
pub right: Box<Term>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl BinaryOperation
|
|
|
|
{
|
|
|
|
pub fn new(operator: BinaryOperator, left: Box<Term>, right: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self
|
|
|
|
{
|
|
|
|
operator,
|
|
|
|
left,
|
|
|
|
right,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-25 19:34:59 +01:00
|
|
|
#[derive(Eq, Hash, Ord, PartialEq, PartialOrd)]
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
pub struct Function
|
|
|
|
{
|
|
|
|
pub declaration: std::rc::Rc<FunctionDeclaration>,
|
|
|
|
pub arguments: Vec<Box<Term>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Function
|
|
|
|
{
|
2020-02-28 15:35:47 +01:00
|
|
|
pub fn new(declaration: std::rc::Rc<FunctionDeclaration>, arguments: Vec<Box<Term>>) -> Self
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
{
|
|
|
|
assert_eq!(declaration.arity, arguments.len(),
|
|
|
|
"function has a different number of arguments then declared");
|
|
|
|
|
|
|
|
Self
|
|
|
|
{
|
2020-02-28 15:35:47 +01:00
|
|
|
declaration,
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
arguments,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-25 19:34:59 +01:00
|
|
|
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
pub enum SpecialInteger
|
|
|
|
{
|
|
|
|
Infimum,
|
|
|
|
Supremum,
|
|
|
|
}
|
|
|
|
|
2020-02-25 19:34:59 +01:00
|
|
|
#[derive(Eq, Hash, Ord, PartialEq, PartialOrd)]
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
pub struct UnaryOperation
|
|
|
|
{
|
|
|
|
pub operator: UnaryOperator,
|
|
|
|
pub argument: Box<Term>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl UnaryOperation
|
|
|
|
{
|
|
|
|
pub fn new(operator: UnaryOperator, argument: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self
|
|
|
|
{
|
|
|
|
operator,
|
|
|
|
argument,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-25 19:34:59 +01:00
|
|
|
#[derive(Eq, Hash, Ord, PartialEq, PartialOrd)]
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
pub struct Variable
|
|
|
|
{
|
|
|
|
pub declaration: std::rc::Rc<VariableDeclaration>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Variable
|
|
|
|
{
|
2020-02-28 15:35:47 +01:00
|
|
|
pub fn new(declaration: std::rc::Rc<VariableDeclaration>) -> Self
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
{
|
|
|
|
Self
|
|
|
|
{
|
2020-02-28 15:35:47 +01:00
|
|
|
declaration,
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Formulas
|
|
|
|
|
2020-02-25 19:34:59 +01:00
|
|
|
#[derive(Eq, Hash, Ord, PartialEq, PartialOrd)]
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
pub struct Compare
|
|
|
|
{
|
|
|
|
pub operator: ComparisonOperator,
|
|
|
|
pub left: Box<Term>,
|
|
|
|
pub right: Box<Term>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Compare
|
|
|
|
{
|
|
|
|
pub fn new(operator: ComparisonOperator, left: Box<Term>, right: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self
|
|
|
|
{
|
|
|
|
operator,
|
|
|
|
left,
|
|
|
|
right,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-25 19:34:59 +01:00
|
|
|
#[derive(Eq, Hash, Ord, PartialEq, PartialOrd)]
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
pub struct Exists
|
|
|
|
{
|
|
|
|
pub parameters: std::rc::Rc<VariableDeclarations>,
|
|
|
|
pub argument: Box<Formula>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Exists
|
|
|
|
{
|
|
|
|
pub fn new(parameters: std::rc::Rc<VariableDeclarations>, argument: Box<Formula>) -> Self
|
|
|
|
{
|
|
|
|
Self
|
|
|
|
{
|
|
|
|
parameters,
|
|
|
|
argument,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-25 19:34:59 +01:00
|
|
|
#[derive(Eq, Hash, Ord, PartialEq, PartialOrd)]
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
pub struct ForAll
|
|
|
|
{
|
|
|
|
pub parameters: std::rc::Rc<VariableDeclarations>,
|
|
|
|
pub argument: Box<Formula>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ForAll
|
|
|
|
{
|
|
|
|
pub fn new(parameters: std::rc::Rc<VariableDeclarations>, argument: Box<Formula>) -> Self
|
|
|
|
{
|
|
|
|
Self
|
|
|
|
{
|
|
|
|
parameters,
|
|
|
|
argument,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-25 19:34:59 +01:00
|
|
|
#[derive(Eq, Hash, Ord, PartialEq, PartialOrd)]
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
pub struct Implies
|
|
|
|
{
|
2020-03-14 02:11:33 +01:00
|
|
|
pub direction: ImplicationDirection,
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
pub antecedent: Box<Formula>,
|
|
|
|
pub implication: Box<Formula>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Implies
|
|
|
|
{
|
2020-03-14 02:11:33 +01:00
|
|
|
pub fn new(direction: ImplicationDirection, antecedent: Box<Formula>, implication: Box<Formula>)
|
|
|
|
-> Self
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
{
|
|
|
|
Self
|
|
|
|
{
|
2020-03-14 02:11:33 +01:00
|
|
|
direction,
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
antecedent,
|
|
|
|
implication,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-25 19:34:59 +01:00
|
|
|
#[derive(Eq, Hash, Ord, PartialEq, PartialOrd)]
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
pub struct Predicate
|
|
|
|
{
|
|
|
|
pub declaration: std::rc::Rc<PredicateDeclaration>,
|
|
|
|
pub arguments: Vec<Box<Term>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Predicate
|
|
|
|
{
|
2020-02-28 15:35:47 +01:00
|
|
|
pub fn new(declaration: std::rc::Rc<PredicateDeclaration>, arguments: Vec<Box<Term>>) -> Self
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
{
|
|
|
|
assert_eq!(declaration.arity, arguments.len(),
|
|
|
|
"predicate has a different number of arguments then declared");
|
|
|
|
|
|
|
|
Self
|
|
|
|
{
|
2020-02-28 15:35:47 +01:00
|
|
|
declaration,
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
arguments,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Variants
|
|
|
|
|
2020-02-25 19:34:59 +01:00
|
|
|
#[derive(Eq, Hash, Ord, PartialEq, PartialOrd)]
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
pub enum Term
|
|
|
|
{
|
|
|
|
BinaryOperation(BinaryOperation),
|
|
|
|
Boolean(bool),
|
|
|
|
Function(Function),
|
|
|
|
Integer(i32),
|
|
|
|
SpecialInteger(SpecialInteger),
|
|
|
|
String(String),
|
|
|
|
UnaryOperation(UnaryOperation),
|
|
|
|
Variable(Variable),
|
|
|
|
}
|
|
|
|
|
|
|
|
pub type Terms = Vec<Box<Term>>;
|
|
|
|
|
|
|
|
impl Term
|
|
|
|
{
|
|
|
|
pub fn absolute_value(argument: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self::unary_operation(UnaryOperator::AbsoluteValue, argument)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn add(left: Box<Term>, right: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self::binary_operation(BinaryOperator::Add, left, right)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn binary_operation(operator: BinaryOperator, left: Box<Term>, right: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self::BinaryOperation(BinaryOperation::new(operator, left, right))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn boolean(value: bool) -> Self
|
|
|
|
{
|
|
|
|
Self::Boolean(value)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn divide(left: Box<Term>, right: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self::binary_operation(BinaryOperator::Divide, left, right)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn exponentiate(left: Box<Term>, right: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self::binary_operation(BinaryOperator::Exponentiate, left, right)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn false_() -> Self
|
|
|
|
{
|
|
|
|
Self::boolean(false)
|
|
|
|
}
|
|
|
|
|
2020-02-28 15:35:47 +01:00
|
|
|
pub fn function(declaration: std::rc::Rc<FunctionDeclaration>, arguments: Vec<Box<Term>>)
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
-> Self
|
|
|
|
{
|
|
|
|
Self::Function(Function::new(declaration, arguments))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn infimum() -> Self
|
|
|
|
{
|
|
|
|
Self::special_integer(SpecialInteger::Infimum)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn integer(value: i32) -> Self
|
|
|
|
{
|
|
|
|
Self::Integer(value)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn modulo(left: Box<Term>, right: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self::binary_operation(BinaryOperator::Modulo, left, right)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn multiply(left: Box<Term>, right: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self::binary_operation(BinaryOperator::Multiply, left, right)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn negative(argument: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self::unary_operation(UnaryOperator::Negative, argument)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn special_integer(value: SpecialInteger) -> Self
|
|
|
|
{
|
|
|
|
Self::SpecialInteger(value)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn string(value: String) -> Self
|
|
|
|
{
|
|
|
|
Self::String(value)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn subtract(left: Box<Term>, right: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self::binary_operation(BinaryOperator::Subtract, left, right)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn supremum() -> Self
|
|
|
|
{
|
|
|
|
Self::special_integer(SpecialInteger::Supremum)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn true_() -> Self
|
|
|
|
{
|
|
|
|
Self::boolean(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn unary_operation(operator: UnaryOperator, argument: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self::UnaryOperation(UnaryOperation::new(operator, argument))
|
|
|
|
}
|
|
|
|
|
2020-02-28 15:35:47 +01:00
|
|
|
pub fn variable(declaration: std::rc::Rc<VariableDeclaration>) -> Self
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
{
|
|
|
|
Self::Variable(Variable::new(declaration))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-25 19:34:59 +01:00
|
|
|
#[derive(Eq, Hash, Ord, PartialEq, PartialOrd)]
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
pub enum Formula
|
|
|
|
{
|
|
|
|
And(Formulas),
|
|
|
|
Boolean(bool),
|
|
|
|
Compare(Compare),
|
|
|
|
Exists(Exists),
|
|
|
|
ForAll(ForAll),
|
2020-03-14 02:11:33 +01:00
|
|
|
IfAndOnlyIf(Formulas),
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
Implies(Implies),
|
|
|
|
Not(Box<Formula>),
|
|
|
|
Or(Formulas),
|
|
|
|
Predicate(Predicate),
|
|
|
|
}
|
|
|
|
|
|
|
|
pub type Formulas = Vec<Box<Formula>>;
|
|
|
|
|
|
|
|
impl Formula
|
|
|
|
{
|
|
|
|
pub fn and(arguments: Formulas) -> Self
|
|
|
|
{
|
|
|
|
assert!(!arguments.is_empty());
|
|
|
|
|
|
|
|
Self::And(arguments)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn boolean(value: bool) -> Self
|
|
|
|
{
|
|
|
|
Self::Boolean(value)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn compare(operator: ComparisonOperator, left: Box<Term>, right: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self::Compare(Compare::new(operator, left, right))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn exists(parameters: std::rc::Rc<VariableDeclarations>, argument: Box<Formula>) -> Self
|
|
|
|
{
|
|
|
|
assert!(!parameters.is_empty());
|
|
|
|
|
|
|
|
Self::Exists(Exists::new(parameters, argument))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn equal(left: Box<Term>, right: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self::compare(ComparisonOperator::Equal, left, right)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn false_() -> Self
|
|
|
|
{
|
|
|
|
Self::boolean(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn for_all(parameters: std::rc::Rc<VariableDeclarations>, argument: Box<Formula>) -> Self
|
|
|
|
{
|
|
|
|
assert!(!parameters.is_empty());
|
|
|
|
|
|
|
|
Self::ForAll(ForAll::new(parameters, argument))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn greater(left: Box<Term>, right: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self::compare(ComparisonOperator::Greater, left, right)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn greater_or_equal(left: Box<Term>, right: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self::compare(ComparisonOperator::GreaterOrEqual, left, right)
|
|
|
|
}
|
|
|
|
|
2020-03-14 02:11:33 +01:00
|
|
|
pub fn if_and_only_if(arguments: Formulas) -> Self
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
{
|
2020-03-14 02:11:33 +01:00
|
|
|
assert!(!arguments.is_empty());
|
|
|
|
|
|
|
|
Self::IfAndOnlyIf(arguments)
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
}
|
|
|
|
|
2020-03-14 02:11:33 +01:00
|
|
|
pub fn implies(direction: ImplicationDirection, antecedent: Box<Formula>,
|
|
|
|
consequent: Box<Formula>) -> Self
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
{
|
2020-03-14 02:11:33 +01:00
|
|
|
Self::Implies(Implies::new(direction, antecedent, consequent))
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn less(left: Box<Term>, right: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self::compare(ComparisonOperator::Less, left, right)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn less_or_equal(left: Box<Term>, right: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self::compare(ComparisonOperator::LessOrEqual, left, right)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn not(argument: Box<Formula>) -> Self
|
|
|
|
{
|
|
|
|
Self::Not(argument)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn not_equal(left: Box<Term>, right: Box<Term>) -> Self
|
|
|
|
{
|
|
|
|
Self::compare(ComparisonOperator::NotEqual, left, right)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn or(arguments: Formulas) -> Self
|
|
|
|
{
|
|
|
|
assert!(!arguments.is_empty());
|
|
|
|
|
|
|
|
Self::Or(arguments)
|
|
|
|
}
|
|
|
|
|
2020-02-28 15:35:47 +01:00
|
|
|
pub fn predicate(declaration: std::rc::Rc<PredicateDeclaration>, arguments: Vec<Box<Term>>)
|
Initial commit
This provides an abstract syntax tree for first-order logic with integer
arithmetics. Initially, the following types of formulas are supported:
- Booleans values (true and false)
- predicates
- negated formulas
- comparisons of terms (<, ≤, >, ≥, =, ≠)
- implications and biconditionals
- conjunctions and disjunctions of formulas
- existentially and universally quantified formulas
In addition, these types of terms are provided:
- Boolean values (true and false)
- integers
- strings
- special integers (infimum and supremum)
- symbolic functions
- variables
- binary operations (addition, subtraction, multiplication, division,
modulo, exponentiation)
- unary operations (absolute value, numeric negation)
2020-02-05 03:17:28 +01:00
|
|
|
-> Self
|
|
|
|
{
|
|
|
|
Self::Predicate(Predicate::new(declaration, arguments))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn true_() -> Self
|
|
|
|
{
|
|
|
|
Self::boolean(true)
|
|
|
|
}
|
|
|
|
}
|