Constraint programming is a form of declarative programming that uses mathematical constraints to define how variables within the program relate to each other. These types of programming techniques typically interact with other types of programming techniques, such as logical and imperative techniques. These logical and imperative techniques do precisely what constraint programming avoids, logically progressing through computational statements and executing changes. Constraint programming is often combined with logic programming to form constraint logic programming, which is an extended version of logic programming. Logic programming includes literal requirements and comparisons of variables, and constraint logic programming extends this to include constraints.
A constraint is an advanced mathematical term, but it is essentially a condition that must be satisfied when making a decision. This is a simplistic definition, and the programming paradigm is best understood when a user has a solid grasp of mathematics. When looking at constraints as they relate to constraint programming, constraints map out how variables in the program must relate to each other.
Declarative programming is a programming paradigm that does not involve dictating how each individual step of a program is carried out, or executed. Instead of focusing on the steps, these types of languages specify or declare computational relationships. Constraint programming is a type of declarative programming because logic is expressed and explained, instead of systematically executed one step at a time.
In computer programming, variables have a definition that can be a bit different from their mathematical definition. A variable can mean anything unless a computer program has defined its meaning. At first glance, when it is said that constraint programming uses constraints to define how variables must relate to each other, it may sound like this is not enough to write an entire computer program with. In reality, because computer programming variables can encompass an unlimited amount of data, defining specifics of how they must relate to each other has a very high level of programming power.
Constraint programming is a programming paradigm, which means it states fundamental ideas about what basic things mean that can be radically different compared to other programming paradigms. Different paradigms can do virtually anything in a different way than another language. One language may use sequential logic, while another one may not. Different paradigms often use different basic blocks of information and relationships to represent instructions. Many things that are fundamental to other programming paradigms, such as logically executing many lines in succession, are not used in constraint programming.