module M = Map.Make(String)        (* o interpretare *)

type bexp = B of bool 
            | V of string
            | Neg of bexp
            | And of bexp * bexp 
            | Or of bexp * bexp
            | Impl of bexp * bexp

let eval m =
  let rec eval1 = function
    | B b -> b
    | V p -> M.find p m
    | Neg e -> not (eval1 e)
    | And (e1, e2) -> eval1 e1 && eval1 e2
    | Or (e1, e2) -> eval1 e1 || eval1 e2
    | Impl (e1, e2) -> not (eval1 e1) || eval1 e2
  in eval1

let m = M.add "a" true (M.add "b" false (M.add "c" true M.empty))
;;

eval m (Impl (V "a", Impl(V "b", V "c")));;

This document was generated using caml2html