I am at a bit of a loss when it comes to understanding how to apply substitution rules for checking if a string is accepted / rejected for a given context-free grammar (CFG).
Suppose I have been given the CFG G, as specified below:
I know the grammar consists of the following:
- Variables: {R, X, S, T}
- Terminals: {a, b}
- R is the start variable
Question
How can I check if the string ab is accepted (i.e. that ab is in L(G))? That is, how does one apply the substitutions rules to reach a conclusion? Is there a good way to backtrack the derivation procedure?
Any help on how to understand this is highly appreciated!

For your given example it is simple to see it, in general (and if you want to implement this on a computer) the standard algorithm to decide the word problem for context free languages is the CYK algorithm (after Cocke-Younger-Kasami).