Weakly stratified logic programs