Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Pda to cfg h2
1. Convert PDA to CFG
• Given a PDA M = (Q, €, F, 6, qO, ZO, {}), we construct a CFG G = (V,
€, P, S)
– V = {[q, A, p] | q, p are in Q, A is in F+{S}}
– P is a set of productions constructed as follows:
• S c [qO, ZO, q] for all q in Q
• for each (p, s) in 6(q, a, A), where a is in € + {s}, we define
production:
[q, A, p] c a € + {s} and B are
in
• for each (p, B1B2…Bm) in 6(q, a, A), where a is
in
F [q, A, qm+1] -> a [q1, B1, q2] [q2, B2, q3] …[qm, Bm, qm+1]
for all q, q1, q2, …, qm+1 in Q
2. Deterministic PDA’s
• A PDA is deterministic if there is at most one move for any
input symbol, any top stack symbol, and at any state.
• A no move or move without advancing input string are
possible in a deterministic PDA.
• A move without advancing input string implies that no
other move exists.
• The pushdown automaton for wcwR is deterministic.
3. Deterministic PDA’s
• The set of languages accepted by deterministic PDD’s is
only a subset of the languages accepted by
nondeterministic PDA’s.
• A regular language is language accepted by a DPDA.
• Not all languages accepted by DPAD are regular.
• All languages accepted by DPAD have an unambiguous
CFG.
• Not all unambiguous languages are accepted by DPAD.
4. Grammatical Format
• Eliminate useless symbols
– derivable from S
– can derive a string of terminals
• Eliminate s-productions
– A -> s is an s-production.
• Eliminate unit productions
– A -> B is a unit production if both A and B are variables.
• For any CFG G and s is not in L(G), there exists
an equivalent context -free grammar with no
useless symbol, s-production, and unit production.
5. Eliminating Useless Symbols
• Given a CFG G = (V, T, P, S), withL(G ) is not empty, we
can effectively find an equivalent CFG G’ = (V’, T, P’, S)
such that for each A in V’ there is some w in T* for which
A=>*w.
• Given a CFG G = (V, T, P, S), we can effectively find an
equivalent CFG G’ = (V’, T’, P’, S) such that for each X in
(V’+T’) there exist a and þ in (V’+T’)* for which
S =>* aXþ.
6. Eliminatingssss-productions
• If s is not in L(G), we can eliminate all s-productions.
• A variable is nullable if A =>* s.
• For A -> X1X2…Xn, add the following productions A ->
Y1Y2…Yn
– If Xi is not nullable, then Yi = Xi.
– If Xi is nullable, then Yi = Xi or Yi = s.
– If Xi is nullable for (i = 1, …, n), don’t add A => s.
7. Eliminating Unit Productions
• If A=>*B and for all nonunit production B->X, add
– A->X
• Eliminate all unit productions.
8. Eliminating Useless Symbols and sss
and Unit Productions
1. Eliminate s-productions
2. Eliminate unit productions
3. Eliminate useless symbols.
9. Chomsky Normal Form (CNF)
• If aCFG has only productions of the form, it is called
Chomsky Normal Form (CNF)
– A -> BC, or
– A -> a
where A, B, and C are variables and a is a terminal.
• Any context-free language with e can be generated by a
context-free grammar in which all productions are in CNF.
10. Chomsky Normal Form (CNF)
• If aCFG has only productions of the form, it is called
Chomsky Normal Form (CNF)
– A -> BC, or
– A -> a
where A, B, and C are variables and a is a terminal.
• Any context-free language with e can be generated by a
context-free grammar in which all productions are in CNF.