function p = BR_Nilsson_query_clause(clause,cc_probs)
% BR_Nilsson_query_clause - find probability of sentence using
%     probabilities of complete conjunction set
% On input:
%     clause (1xk vector): disjunction
%     cc_probs (kx1 vector): complete conjunction probabilities
% On output:
%     p (float): probability of query
% Call:
%     p = BR_Nilsson_query_clause(clause,probs);
% Author:
%     T. Henderson
%     UU
%     Spring 2019
%

num_cc = length(cc_probs);
num_vars = log2(num_cc);
query_sat = ones(1,num_cc);

for cc = 0:num_cc-1
    bits = BR_int2bits(cc,num_vars);
    query_sat(cc+1) = query_sat(cc+1)&BR_sat(clause,bits);
end

p = query_sat*cc_probs;
