Well-formed syntax
- Preface
- Parsing input (SLR parser)
- Parser F# code
- Well-formed syntax
- Semantics of propositional logic
- Constructing tables
- The application
A well formed formula is closely related to the CFG (Context Free Grammar) used in the former chapter. To check whether a formula is well formed, we recursively apply these rules
- ¬: If φ is well-formed, so is ¬φ
- ∧: If φ and ψ are well-formed, so is (φ ∧ ψ).
- ∨: If φ and ψ are well-formed, so is (φ ∨ ψ).
- ⇒: If φ and ψ are well-formed, so is (φ ⇒ ψ).
- ⇔: If φ and ψ are well-formed, so is (φ ⇔ ψ).
Nothing else is a well-formed formula.
To put this into context: if our parser does not return an error, we can brag about how well-formed our input formula is :-).