title: Normalizing and storing boolean expressions (in JavaScript)
body: <p>I have Boolean expression that represent queries which users can enter. They contain brackets and the AND, NOT and OR operators. Example:</p>
  
  <pre><code>(A1 OR B1) AND (NOT C2)
  </code></pre>
  
  <p>For clarification: The expression describes a biological state that can consist of a combination of other parts. E.g., </p>
  
  <pre><code>"(has mutation in gene X) OR (has mutation in gene Y AND has mutation in gene Z)".
  </code></pre>
  
  <p>I need to store it in a way such that if users enter different expressions that describe the same state, I can see they are identical (e.g., <code>A OR A</code> should be normalized to <code>A</code>).</p>
  
  <p>I would like to normalize them and later store the normalized version in a database.</p>
  
  <p>My questions are: 
  1) How should I save them (strings, tree-like structure)?
  2) How should I normalize them based on the saved notation?</p>
  
  <p>Through Google searching I have found references to the Quine–McCluskey algorithm. Would this method be suitable?</p>