Detect integer variables and predicate parameters #2
Reference in New Issue
Block a user
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/nis 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/1andq/1have integer parameters cannot be easily determined because of the cyclic dependency.Placeholders
In cases such as:
where
extis 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
ncould be set to a noninteger value.Comparisons
Let’s say that we have comparisons in our formula:
Here, we can easily conclude that
Xis integer. In the following case,Xis not integer:However, with inequalities, this gets more complicated:
In this case, the inequality strictly doesn’t turn
Xinto 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
Xis an integer variable in cases like the following one:Comparisons
At first, it seems like comparisons of the form
A < Bimply thatAandBare 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,Xwould not be an integer variable, and integer simplifications would be incorrect to apply. However, the program is valid, because there would simply be nonextScoreatom in the output in casecurrentScore/1is 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.