Commit Graph

13 Commits

Author SHA1 Message Date
Patrick Lühne d6a811e363
Move arithmetic check to separate header
Checking whether terms are arithmetic will be used not just in integer
variable detection but also in simplifying formulas with integer
variables. For this purpose, the arithmetic check is moved to a commonly
accessible header file.
2018-04-21 17:59:05 +02:00
Patrick Lühne b1ca027de5
Consolidate commonly used enum classes
This moves the commonly enum classes EvaluationResult, OperationResult,
and Tristate to the Utils header file to avoid code duplication.

Additionally, the SimplificationResult class is replaced by the
semantically similar OperationResult.
2018-04-21 17:34:52 +02:00
Patrick Lühne 28dbd407e2
Extend integer variable detection
If making a variable noninteger turns the entire formula obtained from
completion true, we can drop that statement and conclude that the
variable is integer.
2018-04-21 17:26:15 +02:00
Patrick Lühne f65d4dbbd8
Refactor integer variable detection
This reimplements integer variable detection as two parts. The first one
is a visitor class that recursively searches for all declared variables
in a formula and applies the second part, a custom functor.

Two such functors are implemented. The first one checks whether a
predicate definition is falsified by making a variable noninteger, in
which case it can be concluded that the variable in question is integer.
The second functor checks whether bound variables in a quantified
formula turn the quantified part false, again to conclude that variables
are integer.
2018-04-21 17:02:42 +02:00
Patrick Lühne 8f3ff23f38
Add to-do 2018-04-21 16:58:42 +02:00
Patrick Lühne 03c22d00f5
Remove unwanted detection rule
This piece of code was responsible for propagating the domain of
predicate parameters to argument variables. However, this approach
doesn’t seem to be correct, which is why this commit removes it.
2018-04-21 16:58:42 +02:00
Patrick Lühne 2245e139b2
Reimplement integer variable detection
This is a reimplementation of the integer variable detection procedure.
The idea is to iteratively assume variables to be noninteger, and to
prove that this would lead to a false or erroneous result. If the proof
is successful, the variable is integer as a consequence.
2018-04-20 16:37:48 +02:00
Patrick Lühne 7ba48044ee
Propagate predicate parameter domains
With this change, domains detected for predicate parameters are properly
propagated to all occurences of the respective variables, enabling more
integer simplifications.
2018-04-20 16:37:48 +02:00
Patrick Lühne 862d03881a
Fix typo 2018-04-20 16:37:48 +02:00
Patrick Lühne 159717f51c
Support declaring functions as integer
This adds a new syntax for declaring functions integer:

    #external integer(<function name>(<arity)).

If a function is declared integer, it may enable some variables to be
detected as integer as well.
2018-04-20 16:37:48 +02:00
Patrick Lühne ae918a0846
Moved Domain enum to separate header
For clarity, this moves the Domain enum class to a separate header,
because it’s not just variable-specific but also applicable to
functions, for example.
2018-04-20 16:37:48 +02:00
Patrick Lühne b5b05b766c
Remove Constant class
Constants are not a construct present in Clingo’s AST and were
unintentionally made part of anthem’s AST. This removes the unused
classes for clarity.
2018-04-20 16:37:48 +02:00
Patrick Lühne 165f6ac059
Implement basic integer variable detection
This adds initial support for detecting integer variables in formulas.
The scope is somewhat limited in that variables matching predicate
parameters with known integer type aren’t propagated to be integer as
well yet. Also, the use of constants and functions prevents variables
from being detected as integer, because they have to be assumed to be
externally defined in such a way that they evaluate to general values
and not necessarily integers.
2018-04-20 16:37:48 +02:00