let rec condToDNF cond =
(*Typage : condition --> liste de liste de termes (disjonction de conjonction de termes)
DNF(terme) = {{terme}}
DNF(a or b) = DNF(a) \/ DNF(b)
DNF(a and b) = Composition (DNF(a),DNF(b))
DNF(not a) = tmp = DNF(a)
composition (tmp)
negation de chaque terme
*)
match cond with
| POr (c1, c2) -> (condToDNF c1)@(condToDNF c2)
| PAnd (c1, c2) ->
let d1,d2=(condToDNF c1), (condToDNF c2) in
List.fold_left
(fun lclause clauses2 ->
(List.map
(fun clauses1 ->
clauses1@clauses2
)
d1)@lclause
)
[] d2
| PNot (c) ->
begin
match c with
| POr (c1, c2) -> condToDNF (PAnd(PNot(c1),PNot(c2)))
| PAnd (c1, c2) -> condToDNF (POr (PNot(c1),PNot(c2)))
| PNot (c1) -> condToDNF c1
| _ as t -> [[PNot(t)]]
end
| _ as t -> [[t]]