Context-free grammars (CFGs) provide a formal way to define recursive languages. A CFG consists of variables, terminals, production rules, and a start variable. Production rules specify how variables can be rewritten in terms of terminals and other variables. For example, a CFG for the language of palindromes defines a variable P for palindromes, with rules like P → 0P0 indicating that if a string w is a palindrome, so is 0w0. Derivations apply rules to show that a string is in the language, like deriving a*(a+b000) from the start variable. Parse trees provide an alternative representation of the structure of strings in the language.