Maybe finished NFAs
This commit is contained in:
parent
bb641e26f1
commit
887e2d63c7
3 changed files with 45 additions and 2 deletions
|
|
@ -2,6 +2,7 @@ module Tests
|
|||
|
||||
open System
|
||||
open DFA
|
||||
open NFA
|
||||
|
||||
let numericDFA:DFA = {
|
||||
sigma = Seq.toList "01ab";
|
||||
|
|
@ -19,9 +20,27 @@ let numericDFA:DFA = {
|
|||
acceptingStates = [{name = "yes"}]
|
||||
}
|
||||
|
||||
let numericNFA:NFA = {
|
||||
sigma = Seq.toList "01ab";
|
||||
states = [
|
||||
{name = "yes"}
|
||||
];
|
||||
delta = (fun x y ->
|
||||
match (x, y) with
|
||||
| ({name = "yes"}, '0') -> [{name = "yes"}]
|
||||
| ({name = "yes"}, '1') -> [{name = "yes"}]
|
||||
| _ -> []
|
||||
);
|
||||
beginState = {name = "yes"};
|
||||
acceptingStates = [{name = "yes"}]
|
||||
}
|
||||
|
||||
let test =
|
||||
printfn "Testing numeric checker DFA"
|
||||
printfn "Is valid DFA: %b" (DFA.validateDFA numericDFA)
|
||||
printfn "0101: %b" (DFA.acceptsWord numericDFA "0101")
|
||||
printfn "01a1: %b" (DFA.acceptsWord numericDFA "01a1")
|
||||
printfn "Testing numeric checker NFA"
|
||||
printfn "0101: %A" (NFA.acceptsWord numericNFA "0101")
|
||||
printfn "01a1: %b" (NFA.acceptsWord numericNFA "01a1")
|
||||
0
|
||||
Loading…
Add table
Add a link
Reference in a new issue