Correct normalization of Ctuple

It was not that hard, just had to stop and really
take the time to understand the problem...
This commit is contained in:
Cédric Pasteur 2010-07-28 09:39:31 +02:00
parent ebc1f326b4
commit c2ebaec784

View file

@ -116,27 +116,22 @@ let rec cand nc1 nc2 =
| Aac(ac1), Aac(ac2) -> Aac(Aand(ac1, ac2)) | Aac(ac1), Aac(ac2) -> Aac(Aand(ac1, ac2))
let rec ctuple l = let rec ctuple l =
let rec conv = function let rec norm_or l res = match l with
| Cwrite(n) -> Awrite(n) | [] -> Aac (Atuple (List.rev res))
| Cread(n) -> Aread(n) | Aempty::l -> norm_or l res
| Clastread(n) -> Alastread(n) | Aor (Aempty, nc2)::l -> norm_or (nc2::l) res
| Ctuple(l) -> Atuple (ctuple l) | Aor (nc1, Aempty)::l -> norm_or (nc1::l) res
| Cand (c1, c2) -> Aand (conv c1, conv c2) | Aor(nc1, nc2)::l ->
| Cseq (c1, c2) -> Aseq (conv c1, conv c2) Aor(norm_or (nc1::l) res, norm_or (nc2::l) res)
| Cor (Cempty, c2) -> conv c2 | (Aac ac)::l -> norm_or l (ac::res)
| Cor (c1, Cempty) -> conv c1
| Cempty -> assert false
in in
match l with norm_or l []
| [] -> []
| Cempty::l -> ctuple l
| v::l -> (conv v)::(ctuple l)
and norm = function and norm = function
| Cor(c1, c2) -> cor (norm c1) (norm c2) | Cor(c1, c2) -> cor (norm c1) (norm c2)
| Cand(c1, c2) -> cand (norm c1) (norm c2) | Cand(c1, c2) -> cand (norm c1) (norm c2)
| Cseq(c1, c2) -> cseq (norm c1) (norm c2) | Cseq(c1, c2) -> cseq (norm c1) (norm c2)
| Ctuple l -> Aac(Atuple (ctuple l)) | Ctuple l -> ctuple (List.map norm l)
| Cwrite(n) -> Aac(Awrite(n)) | Cwrite(n) -> Aac(Awrite(n))
| Cread(n) -> Aac(Aread(n)) | Cread(n) -> Aac(Aread(n))
| Clastread(n) -> Aac(Alastread(n)) | Clastread(n) -> Aac(Alastread(n))