Firstly structure Y
is evaluated as an arithmetic expression to give a number. Secondly an attempt is made to match the number to X
. The goal succeeds or fails based on the match.
Examples
?- X is 3.
X = 3
yes
?- X is 3+2.
X = 5
yes
?- X is 3.5+2.25.
X = 5.75
yes
?- 5 is 5.
yes
?- 5 is 6.
no
?- 5 is 4+1.
yes
?- 5 is 4+2.
no
?- X is Y.
Cannot get Numeric for term: Y of type: VARIABLE
?- Z=1+1, Y=9-Z, X is Y.
X = 7
Y = 9 - (1 + 1)
Z = 1 + 1
yes
?- X is _.
Cannot get Numeric for term: _ of type: VARIABLE
?- X is sum(1,2).
Cannot find arithmetic operator: sum/2
?- X is ten.
Cannot find arithmetic operator: ten/0
?- X is [].
Cannot get Numeric for term: [] of type: EMPTY_LIST
?- X is [1,2,3].
Cannot get Numeric for term: .(1, .(2, .(3, []))) of type: LIST