简体   繁体   中英

How to create a deterministic finite automata for the "regular" function where states lead to more than one state depending on the value of an int

the manual of Minizinc says that we can pass an array to the "regular" function that represent the transitions between states of a DFA. For this state machine:

在此处输入图像描述 It puts this example:

array[STATE,SHIFT] of int: t =
 [| 2, 3, 1    % state 1
  | 4, 4, 1    % state 2
  | 4, 5, 1    % state 3
  | 6, 6, 1    % state 4
  | 6, 0, 1    % state 5
  | 0, 0, 1|]; % state 6 

Where the row indicates the state, the first two rows indicate the value of "d" and "n", and the last one is the state that it leads to. However, it doesn't have any examples of how to aproach it if we need to make a state machine where the state can lead to more than one states, or where the variables of excitation aren't boolean. For instance: 在此处输入图像描述

I can't find it in the manual or in Google, thanks.

I am not familiar with Minizinc, but your first question does not depend on that: You are dealing with a deterministic automaton, so each input value can only lead to one other state, otherwise it would be non-deterministic.

As to your second question, if the possible values for x are restricted to 0, 1, 2, and 3, then you could re-phrase this as booleans: in analogy to the d/n/o example, the first column would give the state for x = 0, the second one for x = 1, etc. This does become unwieldy when x can have many values, but should work for your example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM