Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*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 */
- # type eb= Vof int | TRUE | FALSE| AND of eb * eb | OR of eb * eb | XORof eb* eb | NOTof eb;;
- let rec question1 eb =
- let l=[] in
- match eb with
- |OR(a,b)-> if (OR(a,b)=TRUE) then ((l=[(a,TRUE);(b,TRUE)]) || (l=[(a,TRUE);(b,FALSE)]) || (l=[(a,FALSE);(b,TRUE)]))
- else (l=[(a,FALSE);(b,FALSE)])
- |AND(a,b)-> if (AND(a,b)=TRUE) then (l=[(a,TRUE);(b,TRUE)])
- else ((l=[(a,FALSE);(b,FALSE)]) || (l=[(a,TRUE);(b,FALSE)]) || (l=[(a,FALSE);(b,TRUE)]))
- |NOT(a)-> if (NOT(a)=TRUE) then (l=[(a,FALSE)])
- else (l=[(a,TRUE)])
- |XOR(a,b)-> if (XOR(a,b)=TRUE) then ((l=[(a,TRUE);(b,FALSE)]) || (l=[(a,FALSE);(b,TRUE)]))
- else ((l=[(a,FALSE);(b,FALSE)]) || (l=[(a,TRUE);(b,TRUE)]))
- ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement