feat: Floating point arithmetic
This commit is contained in:
parent
f9950a3fd3
commit
4a6850527f
13 changed files with 527 additions and 55 deletions
|
@ -4,6 +4,7 @@ import prolog.Answers
|
|||
import prolog.Substitutions
|
||||
import prolog.ast.arithmetic.ArithmeticOperator
|
||||
import prolog.ast.arithmetic.Expression
|
||||
import prolog.ast.arithmetic.Integer
|
||||
import prolog.ast.arithmetic.Simplification
|
||||
import prolog.ast.logic.Satisfiable
|
||||
import prolog.ast.terms.*
|
||||
|
@ -115,7 +116,6 @@ open class Subtract(private val expr1: Expression, private val expr2: Expression
|
|||
}
|
||||
}
|
||||
|
||||
// TODO Expr * Expr
|
||||
/**
|
||||
* Result = Expr1 * Expr2
|
||||
*/
|
||||
|
@ -129,7 +129,15 @@ class Multiply(private val expr1: Expression, private val expr2: Expression) :
|
|||
}
|
||||
}
|
||||
|
||||
// TODO Expr / Expr
|
||||
class Divide(private val expr1: Expression, private val expr2: Expression) :
|
||||
ArithmeticOperator(Atom("/"), expr1, expr2) {
|
||||
override fun simplify(subs: Substitutions): Simplification {
|
||||
val result = Variable("Result")
|
||||
val map = div(expr1, expr2, result, subs)
|
||||
val simplification = result.simplify(map.first().getOrThrow())
|
||||
return Simplification(this, simplification.to)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Expr mod Expr
|
||||
|
||||
|
|
Reference in a new issue