To answer the question of the title - you can't really predict the future based on past patterns and history, but, you can build probabilities of events happening if similar patterns emerge...
Basically, many stock predictors work on this model - some with surprising accuracy, however there is no good way to account for unforseen events, hence, you can only really build probabilities of what may occur. Of course the more event data you have, the more accurate of a model you can build.
Now, going about actually creating a program for this - you'll want to look into a number of AI techniques probably starting with neural network theory.
Any specific ideas in terms of exactly what sort of data and/or events you are interested in? Or, is it more or less of just a curiosity?