I am trying to write an algorithm that constructs only well-formed formulas in PN. I have some list of symbols for binary connectives, unary connectives, and propositional variables (trying to make program robust for any length).
Here Polish Notation mentions an algorithm to test whether or not it is well-formed. It is much easier to make it so it is well-formed and not to have to test it later for computational purposes. It isn't difficult to make all possible permutations and then test. When looking EKKCprCqrKCpsCqsCApqKrs on the provide link, it seemed that I could "smoosh" the words EKKCCKCCCAK and prqrpsqspqrs at all possible places by creating a bunch of insertion sights, but not sure if this is always correct or can get every possible combination. I am teaching myself these things and having a difficult time thinking how to approach this. I am judging the answer based on explanation and also efficiency to generating wff's.