In SMILES syntax, branches are indicated by balanced pairs of parentheses, an open parenthesis followed at some point by a corresponding close parenthesis. An example is the SMILES string "CCC(OC)CC)SC(ON" which is invalid although it contains an equal number of open and closed parentheses as the second close parenthesis does not have a preceding matching open parenthesis. Ring closures are indicated by a pair of identical ring closure symbols (which we will refer to as the ring-opening symbol and ring-closing symbol based on their order in the string), usually a single digit but which may be two digits preceded by a percent symbol; typically the first ring opening symbol in a SMILES string will use the digit 1, the next 2, and so on, although ring closure symbols may be reused within a SMILES string once a ring is closed. An example of an invalid SMILES due to unmatched ring closure symbols is C1CCCC2. Some approaches to generating SMILES via machine-learning methods use a grammatical definition of the SMILES syntax to ensure that the SMILES generated are valid according to the grammar. Unfortunately, while the context-free grammar used (typically based on that by one of the authors, AD ) does ensure that brackets are matched, it does not (and cannot) enforce the requirement for ring closure symbols to be paired. Thus, for example, the approach of Naruki et al using grammatical evolution or that of Kusner et al using a grammar variational autoencoder still yield problematic SMILES. More recent work by Dai et al uses a syntax-directed variational autoencoder that not only addresses this problem by incorporating a constraint on ring closure symbols, but goes further and incorporates a maximum valence constraint on the atoms. Also relevant here is the work by Janz et al that uses a DNN as a validator during the decoding of SMILES from a latent space of a variational autoencoder.