Matching of two modes
You have seen different types of patterns and how they match with data.
Mode is used to generate facts (statements ). One way is to obtain the fact through inquiry, that is, the pattern matches the data.
Another way to generate facts is to use rules. I will explain it later.
Application rules, that is, matching between modes and data is required.
Before discussing the rules, we need to find out how the two modes match.
Simply put, all depends on the mode variable. Mode variables can be constrained not only into data, but also into other modes.
Constraint to text mode
Constrain the mode variable to the text mode, just like constrain it to the data in the text mode. That's all.
Constraint into another mode variable
If pattern variables A are constrained to B, that is, a is changed to B, they actually become the same pattern variables.
After the pattern variable A is bound to B, B is still free and unrestricted.
- Before binding mode variable B to a value, it is wrong to say that A or B is already constrained.
- No matter which one of the schema variables A or B is bound to a value, you can be sure that B is bound to that value.
- If B is bound to a value, the same value can be obtained by matching with the mode variable A or B.
Regardless of the purpose and intent, pattern variables A and B are the same variables.
A pathological problem
After the two tuples match in one mode, what is the value of the pattern variable $ y constraint:
- Tuples Mode:
- (Ho, $ _, ($ A, $ A), ($ A, $ A, $ B), ($ A, * $ B ))
- Tuples mode B:
The answer is here. Don't peek at it ......