product construction c++

Job ID: 36493202

Budget: €8 – €30 EUR

Create an implementation of product construction (with lazy evaluation, so unreachable states may be omitted) to convert two DFAs to a DFA that gives either the union or the cross-section of both automata. The states of the DFA look like the following: "(p,q)" with p a state of the first DFA and q a state of the second DFA. You implement it so that the following test code works:

#include "DFA.h"

using namespace std;

int main() {
DFA dfa1("input-product-and1.json");
DFA dfa2("input-product-and2.json");
DFA product(dfa1,dfa2,true); // true means cross-section, false means union
product.print();
return 0;
}


with as input for dfa1:
{
"type": "DFA",
"alphabet": [
"x"
],
"states": [
{
"name": "1",
"starting": false,
"accepting": true
},
{
"name": "3",
"starting": false,
"accepting": false
},
{
"name": "2",
"starting": false,
"accepting": false
},
{
"name": "0",
"starting": true,
"accepting": false
}
],
"transitions": [
{
"from": "2",
"to": "2",
"input": "x"
},
{
"from": "0",
"to": "3",
"input": "x"
},
{
"from": "1",
"to": "2",
"input": "x"
},
{
"from": "3",
"to": "1",
"input": "x"
}
]
}

and for dfa2:
{
"type": "DFA",
"alphabet": [
"x"
],
"states": [
{
"name": "1",
"starting": false,
"accepting": true
},
{
"name": "3",
"starting": false,
"accepting": false
},
{
"name": "2",
"starting": false,
"accepting": false
},
{
"name": "0",
"starting": true,
"accepting": false
}
],
"transitions": [
{
"from": "2",
"to": "1",
"input": "x"
},
{
"from": "0",
"to": "2",
"input": "x"
},
{
"from": "3",
"to": "2",
"input": "x"
},
{
"from": "1",
"to": "3",
"input": "x"
}
]
}



(using json)