let choices rf =
let r2ws r = rf;[r] in (* returns the subrelation of rf such that the second component of the pair is exactly r *)
let rec zyva rs = match rs with
|| {} -> { 0 }
|| r ++ rs ->
let wrs = r2ws r in (* subrelation of rf { w -> x | x = r } *)
let rels = zyva rs in (* recursion *)
let rec mapwrs wrs = match wrs with # for all w -> r
|| {} -> {}
|| wr ++ wrs ->
let rec maprels rels = match rels with # for all relations
|| { } -> {}
|| rel ++ rels ->
(wr ++ rel) ++ maprels rels
end in
maprels rels | mapwrs wrs
end in
mapwrs wrs
end in
zyva (range rf)