Note that there are some explanatory texts on larger screens.

plurals
  1. POhaskell: a disjunctive normal form function
    text
    copied!<p>I'm trying to create a function which will change a proposition into disjunctive normal form. </p> <p>It will do this by reading in a list of Valuation :</p> <pre><code>type Valuation = [(Variable, Bool)] -- Valuation of variables to truth values </code></pre> <p>and using these:</p> <pre><code>findBool :: (Variable, Bool)-&gt;Bool findBool (_,x) = x findVar :: (Variable, Bool)-&gt;Variable findVar (x,_) = x </code></pre> <p>Also Proposition is:</p> <pre><code>data Prop = Falsum -- a contradiction, or | Var Variable -- a variable, or | Not Prop -- a negation of a formula, or | Or Prop Prop -- a disjunction of two formulae, or | And Prop Prop -- a conjunction of two formulae, or | Imp Prop Prop -- a conditional of two formulae. deriving (Eq, Show) </code></pre> <p>I think what I have so far is pretty solid but I can't see what to do for the empty case. Here's what I have so far:</p> <pre><code>minterm :: Valuation -&gt; Prop minterm [] = ? minterm (x:xs) = if (findBool x) then (And (findVar x) (minterm xs)) else (And (Not(findVar x) (minterm xs)) </code></pre> <p>my goal is for:<code>minterm [("p",True),("q",False)]</code> to return: <code>And (Var "p") (Not (Var "q"))</code></p> <p><strong>edit:</strong> Not Falsum works but I'd prefer if it didn't return anything. Is there anyway I can exclude cases where it would be returned so I can get something like this:</p> <p><code>minterm [("p",True),("q",False)]</code> == <code>And (Var "p") (Not (Var "q"))</code></p>
 

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