m (grammatical edits, punctuation edits) |
No edit summary |
||
Line 25: | Line 25: | ||
Note: this only works in version 1.2.7 of ProB; this feature has not yet been enabled in 1.3.0. | Note: this only works in version 1.2.7 of ProB; this feature has not yet been enabled in 1.3.0. | ||
* Another solution is try and write your function constructively and non-recursively, ideally using a lambda abstraction: | |||
parity : (NATURAL --> {0,1}) & | |||
parity = %x.(x:NATURAL|x mod 2) | |||
Here ProB detects that parity is an infinite function and will keep it symbolic (if possible). | |||
With such an infinite function you can: | |||
** apply the function <tt>parity(10001)</tt> is the value <tt>1</tt> | |||
** compute the image of the function, e.g., <tt>parity[10..20]</tt> is <tt>{0,1}</tt> | |||
** compose the function with a finite relation, e.g., <tt>(id(1..10) ; parity)</tt> gives the value <tt>[1,0,1,0,1,0,1,0,1,0]</tt> | |||
** sometimes compute the domain of the function, here, <tt>dom(parity)</tt> is determined to be <tt>NATURAL</tt>. But this only works for simple infinite functions represented. |
Take the following function:
CONSTANTS parity PROPERTIES parity : (NATURAL --> {0,1}) & parity(0) = 0 & !x.(x:NATURAL => parity(x+1) = 1 - parity(x))
Here, ProB will complain that it cannot find a solution for parity. The reason is that parity is a function over an infinite domain, but ProB has to represent the function as a finite set of maplets.
There are basically three solutions to this problem:
parity : (NAT --> {0,1}) & parity(0) = 0 & !x.(x:NAT & x<MAXINT => parity(x+1) = 1 - parity(x))
of parity greater than x: parity : (NATURAL --> {0,1}) & parity(0) = 0 & !x.(x:NATURAL1 => parity(x) = 1 - parity(x-1))
Note: this only works in version 1.2.7 of ProB; this feature has not yet been enabled in 1.3.0.
parity : (NATURAL --> {0,1}) & parity = %x.(x:NATURAL|x mod 2)
Here ProB detects that parity is an infinite function and will keep it symbolic (if possible). With such an infinite function you can: