Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One place to get you started: look at</p> <pre><code> removeTautologies :: Formula -&gt; Formula </code></pre> <p>Now suppose we can write an function</p> <pre><code> isTautology :: Clause -&gt; Bool </code></pre> <p>Then we may have a chance of using that function to <em>filter</em> general formulae. So I would attempt to ignore everything but the function <code>isTautology</code>. Essentially the question here is: <em>What is a tautology</em> and <em>how do we detect it?</em> Some of the ideas posted by Edward Z. Yang should definitely help you here in understanding what is going on. In this case, we could look at the clause <code>[(True,"A"), (True,"B"), (False,"A")]</code> and try to feed it to <code>isTautology</code> for testing it. Likewise with the other clause Edward posted, <code>[(True,"B"), (True,"C"), (True,"A")]</code>.</p> <p>The trick in general is to figure out how to break up the functions into smaller constituents which are easily written and then afterwards glue these individual pieces together with code to solve the final problem. We are decomposing <code>removeTautologies</code> which works on general formulae into a helper <code>isTautology</code> which can work on clauses in the formula, and then we seek to define <code>removeTautologies</code> in terms of it via some <em>filtering</em> glue code.</p> <p>I hope this helps you start on your problem. It may seem to be quite irrelevant but do take note that more advanced variants of this is used in Model Checking algorithms which verify that your CPU is correct, that protocols behave and recently is has also been used in automatic refactoring, see <a href="http://coccinelle.lip6.fr/" rel="nofollow">http://coccinelle.lip6.fr/</a> for a use. So this problem is a good way to learn some serious applicability in the real world!</p> <hr> <p>I'll edit it here to help you rather than replying in the comment section. You wrote:</p> <pre><code>rt ((x, x') : (y, y') : rest) | x' == y' = rt rest | otherwise = (x, x') : rt ((y, y') : rest) </code></pre> <p>There are a couple of problems with this approach as you mention. First, the game is that your <code>rt</code> function is working on clauses. If the given clause is a tautology it should be removed, so it would be better to call it <code>isTautology</code> with the type I mention above, or perhaps simply:</p> <pre><code>isRemovableClause :: Clause -&gt; Bool </code></pre> <p>The path you have taken requires you to sort the list in the clause lexicographically and then consider what to do in the case you have <code>[P, P, not P, Q]</code> for instance. Another approach is to establish a search. Suppose we have</p> <pre><code>isRemovableClause ((tv, name) : rest) = ... </code></pre> <p>Notice that if the value <code>(not tv, name)</code> is present in <code>rest</code> this clause must be a tautology. Otherwise, we can throw away <code>(tv, name)</code> and look for a tautology in <code>rest</code>.</p> <p>Moving the focus to <code>removeTautologies</code>, it is clear that the function can be written using <code>isRemovableClause</code>: A formula is a list of clauses, so we can simply walk through the clause-list and remove all those for which <code>isRemovableClause</code> returns true. The bold solver will use <code>List.filter</code>, a higher order function, to achieve this.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload