Project Ocaml (help)

ray17 May 8th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*I want to implement in Ocaml a Boolean solver, that is to say an algorithm to calculate the set of solutions of a system of boolean equations. the first step is to determine the set of variables in the system of equations. The first will result in the list [V1; V2; V3] . I code this but it's false , i don't know how to begin */
  3. # type eb= Vof int | TRUE | FALSE| AND of eb * eb | OR of eb * eb | XORof eb* eb | NOTof eb;;
  4. let rec question1 eb =
  5. let l=[] in      
  6. match eb with
  7. |OR(a,b)-> if (OR(a,b)=TRUE) then ((l=[(a,TRUE);(b,TRUE)]) || (l=[(a,TRUE);(b,FALSE)]) || (l=[(a,FALSE);(b,TRUE)]))
  8.             else (l=[(a,FALSE);(b,FALSE)])
  9. |AND(a,b)-> if (AND(a,b)=TRUE) then (l=[(a,TRUE);(b,TRUE)])
  10.             else ((l=[(a,FALSE);(b,FALSE)]) || (l=[(a,TRUE);(b,FALSE)]) || (l=[(a,FALSE);(b,TRUE)]))
  11. |NOT(a)-> if (NOT(a)=TRUE)  then (l=[(a,FALSE)])
  12.             else (l=[(a,TRUE)])
  13. |XOR(a,b)-> if (XOR(a,b)=TRUE) then ((l=[(a,TRUE);(b,FALSE)]) || (l=[(a,FALSE);(b,TRUE)]))
  14.                 else ((l=[(a,FALSE);(b,FALSE)]) || (l=[(a,TRUE);(b,TRUE)]))
  15. ;;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand