Non-horn magic sets to incorporate top-down inference into bottom-up theorem proving