Here is the code for a minimal BDD manager written in Ocaml: tinybdd.ml.

Build and use instructions

ocamlc tinybdd.ml
ocaml tinybdd.cmo
# open Tinybdd;;

The commands above compile the code, and launch a shell that first executes tinybdd.ml, then asks for further input. You can play more with it. Here is an example of an interactive session:

> ocamlc -g tinybdd.ml
> ocaml tinybdd.cmo
        Objective Caml version 3.10.0

# open Tinybdd;;
# let a = m#bdd_literal 2;;
val a : int = 2
# let b = m#bdd_literal 5;;
val b : int = 3
# let c = m#bdd_and a b;;
val c : int = 4
# m#print_bdd c;;

(x_2 = 0:
 (false))
(x_2 = 1:
 (x_5 = 0:
  (false))
 (x_5 = 1:
  (true))
)
- : unit = ()
# m#print_bdd_table ;;
  0) Var:  0 F:   0 T:   0
  1) Var:  0 F:   0 T:   0
  2) Var:  2 F:   0 T:   1
  3) Var:  5 F:   0 T:   1
  4) Var:  2 F:   0 T:   3
- : unit = ()
# 

The Assignment

You need to write the following class methods:

Email me a single .ml file that contains the above definitions, along with some simple testing code for the required functions (see the source file for an example).

The catches

I am not 100% sure that my code is correct; you will have to fix it as part of the assignment. Ocaml has a very nice compiler available, called ocamldebug; if you run into trouble, use it.

ocamlc -g tinybdd.ml
ocamldebug a.out

Note that in this way, you cannot use the interactive Ocaml shell.

Resources

CMPE 278 2007 HW 3 (last edited 2007-10-19 09:56:51 by LucaDeAlfaro)