From f678494b523a13b8b288421ef165e3d0bf081e70 Mon Sep 17 00:00:00 2001 From: Kia <kia@special-circumstanc.es> Date: Sat, 15 Aug 2020 21:28:05 -0600 Subject: [PATCH] finished pseudocode --- cfg_utils.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/cfg_utils.py b/cfg_utils.py index ebb77a2..6e04d1b 100644 --- a/cfg_utils.py +++ b/cfg_utils.py @@ -309,6 +309,7 @@ if __name__ == '__main__': # Special case 1: k is T_ij, and thus x_ijk is the last symbol in the production rule. # Special case 2: The symbol x_ijk is a terminal symbol. +# The exhaustive case analysis is as follows. # /----------------------------------------------------------\ # |X_ijk is a terminal symbol | X_ijk is a nonterminal symbol| @@ -325,6 +326,39 @@ if __name__ == '__main__': # | Fprim(i, j, k+1, N-1) | symbols in the subset of rule| # \----------------------------------------------------------/ +# We also note that for the degenerate case N=0, we always can and must return the empty array [] + +# In pseudocode (taken from the paper, with the correction that on top of page 5 +# the "if N==0 then return [1]" seems like it should be "if N==1 then return [1]"): + +# Fprim(i, j, k, N): +# if (N==0) return [] +# if X_ijk is a terminal: +# if k==T_ij: +# # CASE A +# if N==1 return [1], else return [0] +# if k != T_ij: +# # CASE B +# return [sum(Fprim(i, j, k+1, N-1))] +# else if X_ijk is a nonterminal: +# if k=T_ij: +# # CASE C +# return [sum(Fzero(index of nonterminal at index k, N))] +# if k != T_ij +# # CASE D +# return [sum(Fzero(index of nonterminal at index k, L)) * +# sum(Fprim(i, j, k+1, N-L)) for L = [1, N - T_ij + k]] + + + + + + + + + + + -- GitLab