I’ve encountered a new error while converting my last function to use the
new dataviewtype:
dataviewtype GREXP =
| GRgenes of genes
| GRconj of genes
| GRconj of (GREXP,GREXP)
| GRdisj of genes
| GRdisj of (GREXP,GREXP)
The function; red highlight is where there error occurs. I also wonder if
declaring sequential vals is appropriate, or if it is better to use var
(yellow highlight):
fun toCNF (bexp: !GREXP): GREXP = let
val LR = case+ bexp of
| GRconj(!ex1,!ex2) => let
val retv = (toCNF(!ex1),toCNF(!ex2))
val _ = $showtype retv
prval () = fold@ bexp
in retv end
| GRdisj(ex1,ex2) => (toCNF(ex1),toCNF(ex2))
| GRgenes(g) => (bexp, bexp) // ?
in case+ bexp of
| GRgenes(!g) => (fold@ bexp; bexp) //Start here
| GRconj(!ex1,!ex2) => (case+ (LR.0,LR.1) of
| (GRgenes(g1), GRgenes(g2)) => let
var setu = linset_union(!g1,!g2)
val _ = linset_free(g1)
val _ = linset_free(g2)
in
(fold@ bexp; GRconj setu)
end
| (,) => (fold@ bexp; GRconj(!ex1,!ex2))
)
| GRdisj(!ex1,!ex2) => (case+ (LR.0,LR.1) of
// Handle disjunctive cases:
| (GRdisj(lx1,lx2), GRdisj(rx1,rx2)) => let //GRdisj(LR.0,LR.1)
val setu = linset_union(!lx1,!lx2)
val setu = linset_union(setu,!rx1) //Any memory lost here?
val setu = linset_union(setu,!rx2)
val _ = linset_free(lx1)
val _ = linset_free(lx2)
val _ = linset_free(rx1) //shouldn’t be able to free ?
val _ = linset_free(rx2)
in GRdisj setu end
| (GRdisj(lx1,lx2), GRgenes(g)) => let //GRdisj(LR.0,!ex2)
val setu = linset_union(!lx1, !lx2)
val setu = linset_union(setu, g)
val _ = linset_free(lx1)
val _ = linset_free(lx2)
val _ = linset_free(g)
in GRdisj setu end
| (GRgenes(g), GRdisj(rx1,rx2)) => let // GRdisj(!ex1,LR.1)
val setu = linset_union(!rx1, !rx2)
val setu = linset_union(setu, g)
val _ = linset_free(rx1)
val _ = linset_free(rx2)
val _ = linset_free(g)
in GRdisj setu end
| (GRgenes(g1), GRgenes(g2)) => let
var setu = linset_union(!g1,!g2)
val _ = linset_free(g1)
val _ = linset_free(g2)
in
GRdisj setu
end
// Distribute OR over ANDs:
| (GRconj(lx1,lx2),GRconj(rx1,rx2)) =>
GRconj(GRconj(GRconj(toCNF(GRdisj(lx1,rx1)),toCNF(GRdisj(lx2,rx1))),
toCNF(GRdisj(lx1,rx2))),toCNF(GRdisj(lx2,rx2)))
// Handle e.g.: (… OR …) OR (… AND …)
| (GRconj(lx1,lx2), ) =>
GRconj(toCNF(GRdisj(lx1,LR.1)),toCNF(GRdisj(lx2,LR.1)))
| ( ,GRconj(rx1,rx2)) =>
GRconj(toCNF(GRdisj(LR.0,rx1)),toCNF(GRdisj(LR.0,rx2)))
)
end
And the error (I’m not sure what lower bound means here):
SHOWTYPE(/media/RAID5/share/ATS_learning/toCNF3.dats: 11274(line=428,
offs=27) – 11278(line=428, offs=31)): S2Etyrec(flt; 0; 0=S2Ecst(GREXP),
1=S2Ecst(GREXP))
/media/RAID5/share/ATS_learning/toCNF3.dats: 11320(line=430, offs=12) –
11324(line=430, offs=16): error(3): sort mismatch: the sort of [s2V(3185)]
is [t@ype], but the sort of its lower bound is [viewt@ype].
/media/RAID5/share/ATS_learning/toCNF3.dats: 11320(line=430, offs=12) –
11324(line=430, offs=16): error(3): mismatch of static terms (tyleq):
The needed term is: S2EVar(3185)
The actual term is: S2Etyrec(flt; 0; 0=S2Ecst(GREXP), 1=S2Ecst(GREXP))
exit(ATS): uncaught exception:
_2fhome_2ffac2_2fhwxi_2fresearch_2fATS_2fIMPLEMENT_2fGeizella_2fAnairiats_2fsvn_2fats_2dlang_2fsrc_2fats_error_2esats__FatalErrorException(1233)