Note that there are some explanatory texts on larger screens.

plurals
  1. PORPAREN EQALOP and unbound variable and constructor errors in SML/ML
    text
    copied!<p>Said I have got 2 CNF logical phrases a,b and my distrib function should return the CNF form of a|b (a OR b).</p> <p>Replacing rules that I've got are:</p> <pre><code>1) Replace p|(q&amp;r) by (p|q)&amp;(p|r) 2) Replace (q&amp;r)|p by (q|p)&amp;(r|p) </code></pre> <p>A prop defined this way:</p> <pre><code>datatype prop = Atom of string | Not of prop | And of prop*prop | Or of prop*prop; </code></pre> <p>The function:</p> <pre><code>local fun doOr(prop1,prop2) = (Or(prop1,prop2)) fun distrib1 (Or(Atom(sName1),Atom(sName2) ) ) = Or(Atom(sName1), Atom(sName2) ) |distrib1 (Or(Not(Atom(sName1) ),Atom(sName2) ) ) = Or(Not(Atom(sName1) ), Atom(sName2) ) | distrib1 (Or(Atom(sName1),Not(Atom(sName2) ) ) ) = Or(Atom(sName1), Not(Atom(sName2) ) ) | distrib1 (Or(Not(Atom(sName1)),Not(Atom(sName2) ) ) ) = Or(Not(Atom(sName1)), Not(Atom(sName2) ) ) | distrib1 (Or(prop1,And(prop2,prop3) ) ) = And( distrib1(Or(prop1,prop2) ), distrib1(Or(prop1,prop3) ) ) | distrib1 (Or(And(prop1, prop2), prop3) ) ) = And( distrib1(Or(prop1,prop3) ), distrib1(Or(prop2,prop3) ) ) in fun distrib (prop1,prop2) = distrib1(doOr(prop1,prop2) ); end; </code></pre> <p>Well, I don't know if the function itself is right although I just went through all the base options and the replacing rules but for now I get the above errors when the EQALOP appear after the distrib1 function and the constructors error appear the distrib function.</p> <p>Why I get those errors? I am not sure but maybe I am supposed to use let and not local but then how can I transform it to a let structure?</p> <p>Thanks.</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