I am working on a university project in Programming in Logic. I have to develop an automaton that performs a series of restrictions. One of which is to guarantee that the number 2 has a 4 to it's left and right (only 2) Also, the 4's must be at the same distance as the 2 ([00424] [40204])
For that, I am counting the number of spaces (0's) between the first 4 and the 2 and the decrease the counter until i find the last 4. I want to restrict that if the counter (C) is equal to 0 than it can transit to the final state s3. Because the word can have any length I cannot adopt any other strategy.
I am just having difficulty restricting the counter... I have searched the documentation and tried to implement different things in the arc to s3.
Tried
arc(s2, 4, s3, C#=0)
,
arc(s2, 4, s3, (C#=0))
, arc(s2, 4, s3, [C#=0])
, but none were right..
Can anyone help me?
automaton(Line, _, Line, [source(s), sink(s3), sink(o2)],
[
arc(s, 0, s),
arc(s, 1, o3),
arc(s, 4, s1),
arc(s1, 0, s1, [C+1]),
arc(s1, 2, s2),
arc(s1, 3, s4),
arc(s1, 4, o1),
arc(s2, 0, s2, [C-1]),
arc(s2, 4, s3), %here is where I want to restric C to be equal to 0
arc(o1, 0, o1),
arc(o1, 1, o2),
arc(o2, 0, o2),
arc(o3, 0, o3),
arc(o3, 4, o4),
arc(o4, 0, o4),
arc(o4, 4, o2),
arc(s3, 0, s3),
arc(s4, 0, s4, [C-1]),
arc(s4, 4, s3)
],
[C], [0], [_N]
).