function KB_out = BR_KB_insert_clause(KB,clause)
% BR_KB_insert_clause - insert a new clause into KB
% On input:
%     KB (KB data structure): knowledge base of disjunctions
%     clause (1xn vector): clause of literals
% On output:
%     KB_out (KB data structure): KB with new clause
% Call:
%     KB1 = BR_KB_insert_clause(KB,[2]);
% Author:
%     T. Henderson
%     UU
%     Fall 2017
%

KB_out = KB;

num_clauses = length(KB);
clause = sort(unique(clause));
len_clause = length(clause);
for s = 1:num_clauses
    KB_clause = KB(s).clauses;
    if (length(KB_clause)==len_clause)&(min(KB_clause==clause)==1)
        return
    end
end
num_clauses = num_clauses + 1;
KB_out(num_clauses).clauses = clause;
KB_out(num_clauses).prob = 0;
