Detect integer variables and predicate parameters #2
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In order to apply simplifications that only apply to integer variables, these need to be detected first.
If a parameter of a predicate
p/n
is described by an integer variable (in all occurrences) in the definition ofp/n
, then this parameter is integer as well, denoted byDifficulties
Cyclic Dependencies
How to handle cases such as:
Whether
p/1
andq/1
have integer parameters cannot be easily determined because of the cyclic dependency.Placeholders
In cases such as:
where
ext
is declared#external
, we cannot conclude the domain ofX
.Constants
When programs include constants (syntactically, 0-ary functions), we cannot assume them to be integer:
because
n
could be set to a noninteger value.Comparisons
Let’s say that we have comparisons in our formula:
Here, we can easily conclude that
X
is integer. In the following case,X
is not integer:However, with inequalities, this gets more complicated:
In this case, the inequality strictly doesn’t turn
X
into an integer variable. However, detecting such negations is complicated, because they might also occur at a higher level up the syntax tree.Functions
Generally, functions can return any type of objects. Hence, it’s not safe to assume that
X
is an integer variable in cases like the following one:Comparisons
At first, it seems like comparisons of the form
A < B
imply thatA
andB
are arithmetic expressions returning an integer.However, this may not be true in some cases. Consider the following part of what could be a game description:
Let’s assume that
currentScore(error)
is set to handle situations where some illegal action was taken. Then,X
would not be an integer variable, and integer simplifications would be incorrect to apply. However, the program is valid, because there would simply be nonextScore
atom in the output in casecurrentScore/1
is not present with an integer argument.Detect integer variables and predicatesto Detect integer variables and predicate parametersImplemented by hypothetically making variables noninteger and checking whether this leads to trivially true or false statements, from which it can be concluded that the variables must be integer.