Satisfaction Guaranteed
Consider a very simple programming language, with only three types of statements:
if then fi
if then else fi
checkpoint
All keywords are required to consist of all lower case letters. A is obviously just a list of one or more statements, and an entire program is a single .
A consists of:
Variables: a single capital letter
Operators: unary (NOT), binary (AND), binary | (OR).
Precedence: > > |
Parentheses
NO Spaces
→ or or | or () or [A-Z]
Given a syntactically correct program in this simple language, what values must the boolean variables hold in order to satisfy each of the checkpoints?
Input
Input will be a single syntactically correct program in this simple language. Keywords are guaranteed to be in all lower case, and boolean variables are guaranteed to each be a single upper case letter. White space (space, tab or newline) is guaranteed to separate keywords, and surround expressions. Expressions will not contain whitespace. Every will contain at least one statement. The input program will not use more than 20 of the available variables, and will not contain more than 5000 statements. No Boolean expression will be longer than 128 characters.
Output
For each checkpoint, in the order they appear, output a single line, consisting of '>' followed by either a list of variables, or the word 'unreachable'. If the checkpoint is reachable, output a list of variables, in alphabetical order, with an upper case letter if it must be true, or a lower case letter if it must be false to reach the checkpoint. Omit the variable if it can be either. If the checkpoint is not reachable, then output the word 'unreachable', entirely in lower case. Do not print any spaces, and do not print any blank lines between lines of output.