40 likes | 137 Views
The Even Query. % Express the even query without assuming a total order (i.e., use choice) item (a) . item(cc). item(bb). seq (nil , nil ). seq (X, Y ) <- seq (_, X), item(Y), choice((X), (Y)), choice((Y), (X)). even(nil). odd(Y ) < - even(X), seq (X, Y).
E N D
The Even Query %Express the even query without assuming a total order (i.e., use choice) item(a). item(cc). item(bb). seq(nil, nil). seq(X, Y) <- seq(\_, X), item(Y), choice((X), (Y)), choice((Y), (X)). even(nil). odd(Y) <- even(X), seq(X, Y). even(Z) <- odd(Y), seq(Y, Z). evencount<- even(Z), ~seq(Z, \_). %but no recursive query is actually needed pair(X, Y) <- item(Y), item(Y), Y~=X, choice((X), (Y)), choice((Y), (X)). odd <- item(X), ~pair(X, _). even <- ~odd.
How soon for each part delivery(Part, fsmax<Days>) <- basic(Part, Days). delivery(Part, fsmax<Days>) <- assbl(Part, Sub), delivery(Sub, Days). actualDays(Part, max<Days>) <- delivery(part, Days). % %An extension of the seminaivefixpoint to efficiently execute this program % ddelivery(0, Part, max<Days>) <- basic(Part, Days). %here the compiler will use max--but for the example at hand there is only %Day for each basic part. ddelivery(J+1, Part, max<Days>) <- assbl(Part, Sub), ddelivery(J, Sub, Days), if(all(J, Part, D2) then D2<Days). all(J+1, Part, Days) < all(J, Part, Days), ~ddelivery(J+1, Part, Days). all(J+1, Part, Days) <- ddelivery(J+1, Part, Days).
How soon for each part delivery(Part, fsmax<Days>) <- basic(Part, Days). delivery(Part, fsmax<Days>) <- assbl(Part, Sub), delivery(Sub, Days). actualDays(Part, max<Days>) <- delivery(part, Days). %An extension of the seminaivefixpoint to efficiently execute this program ddelivery(0, Part, max<Days>) <- basic(Part, Days). ddelivery(J+1, Part, max<Days>) <- assbl(Part, Sub), ddelivery(J, Sub, Days), ~later(J, Part, Days) later(J, Part, Days) <- all(J, Part, D2), D2<Days. all(J+1, Part, Days) < all(J, Part, Days), ~ddelivery(J+1, Part, Days) all(J+1, Part, Days) <- ddelivery(J+1, Part, Days). basic(bolt, 2). basic(nut, 4). assb(frame, bolt). assb(bike, nut). assb(bike, frame). We thus get: ddelivery(0, bolt, 2). ddelivery(0, nut, 4). Then ddelivery(1, frame, 2). ddelivery(1, bike, 4). ddelivery(2, bike, 2) %from frame … we must compare against ddelivery(1, bike, 4). Obtained at the previous step.!!!!
Stratification all(J+1, Part, Days) <- all(J, Part, Days), ~ddelivery(J+1, Part, Days). all(J+1, Part, Days) <- ddelivery(J+1, Part, Days). ddelivery(J+1, Part, max<Days>) <-assbl(Part, Sub), ddelivery(J, Sub, Days), ~later(J, Part, Days) later(J, Part, Days) <- all(J, Part, D2), D2<Days.