function x=greedy(pe,rank_func)
% pe: permutation over ground set
% rank_func: rank oracle
m=numel(pe);
n=rank_func(true(1,m));
x=false(1,m);ind=1;i=0;
while i<n% Until a base is reached
    y=x;y(pe(ind))=true;
    ind=ind+1;
    [i,b]=rank_func(y);
    if b;x=y;end% Add element if independent
end
end