Add complement of DFA
This commit is contained in:
parent
2708e66b19
commit
94699949eb
1 changed files with 11 additions and 1 deletions
12
DFA.fs
12
DFA.fs
|
|
@ -69,4 +69,14 @@ let rec processCharArray (dfa: DFA) (state: String) (charArr: Char list) =
|
|||
/// Returns whether the DFA accepts this word
|
||||
let acceptsWord (dfa: DFA) (word: String) =
|
||||
dfa.acceptingStates
|
||||
|> List.contains (processCharArray dfa dfa.beginState (Seq.toList word))
|
||||
|> List.contains (processCharArray dfa dfa.beginState (Seq.toList word))
|
||||
|
||||
let complement (dfa: DFA) : DFA =
|
||||
{
|
||||
sigma = dfa.sigma;
|
||||
states = dfa.states;
|
||||
delta = dfa.delta;
|
||||
beginState = dfa.beginState;
|
||||
acceptingStates = dfa.states
|
||||
|> List.filter (fun x -> not (List.contains x dfa.acceptingStates))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue