UnifyTerms unifies two same-length lists of relational terms. It does not handle apply-expressions.
(xs []ast.BaseTerm, ys []ast.BaseTerm)
| 142 | // UnifyTerms unifies two same-length lists of relational terms. It does not handle |
| 143 | // apply-expressions. |
| 144 | func UnifyTerms(xs []ast.BaseTerm, ys []ast.BaseTerm) (UnionFind, error) { |
| 145 | if len(xs) != len(ys) { |
| 146 | return UnionFind{}, fmt.Errorf("not of equal size") |
| 147 | } |
| 148 | uf := UnionFind{make(map[ast.BaseTerm]ast.BaseTerm)} |
| 149 | var newXs []ast.BaseTerm |
| 150 | var newYs []ast.BaseTerm |
| 151 | for i, x := range xs { |
| 152 | y := ys[i] |
| 153 | if x.Equals(ast.Variable{"_"}) || y.Equals(ast.Variable{"_"}) { |
| 154 | continue |
| 155 | } |
| 156 | uf.parent[x] = x |
| 157 | uf.parent[y] = y |
| 158 | newXs = append(newXs, x) |
| 159 | newYs = append(newYs, y) |
| 160 | } |
| 161 | return uf, unifyTermsUpdate(newXs, newYs, uf) |
| 162 | } |
| 163 | |
| 164 | // UnifyTermsExtend unifies two same-length lists of relational terms, returning |
| 165 | // an extended UnionFind. It does not handle apply-expressions. |