title: Prolog program structure for constraint solution analysis
body: <p>I have a SWI-PROLOG program with the following structure:</p>
  
  <pre><code>% various predicates
  ...
  ...
  ...
  
  main :-
     % constraints
     ...
     ...
     ...
     % labeling of about 50 variables
     label([........]),
     % additional conditions and constraints:
     condition1
     condition2
     ...
     conditionN
     % output
     write(Interesting_var),nl.
  </code></pre>
  
  <p>The constraint solver works reasonably fast (for about 10 seconds) and finds many answers.  Then I can filter the answers with the help of <code>condition1</code>,...,<code>conditionN</code> and print <code>Interesting_var</code>.</p>
  
  <p><strong>Problem 1:</strong> I have to run this many times with different <code>condition1</code>,...,<code>conditionN</code>. So I am modifying the program each time I run it.  But what if the constraints were solved not for 10 seconds but for 10 minutes or 10 hours?  How can I remember all solutions of the constraints and then ask specific questions about the values of about 50 interesting variables in the constraints.</p>
  
  <p><strong>Problem 2:</strong> I have about 50 interesting variables at present. But I am constantly adding new variables and new constraints. The <code>main</code> predicate is getting longer and longer... How can I make my program more modular. Semantically these variables can be grouped into few "domains", however in my program they all are defined in one place.</p>