evalDiamondMinus implements the diamond-minus operator (<-). It returns true if the atom was true at SOME point in the past interval. Syntax: <-[d1, d2] p(X) means "p(X) was true at some point between d1 and d2 ago"
( atom ast.Atom, opInterval ast.Interval, interval *ast.Interval, subst unionfind.UnionFind, )
| 159 | // It returns true if the atom was true at SOME point in the past interval. |
| 160 | // Syntax: <-[d1, d2] p(X) means "p(X) was true at some point between d1 and d2 ago" |
| 161 | func (te *TemporalEvaluator) evalDiamondMinus( |
| 162 | atom ast.Atom, |
| 163 | opInterval ast.Interval, |
| 164 | interval *ast.Interval, |
| 165 | subst unionfind.UnionFind, |
| 166 | ) ([]unionfind.UnionFind, error) { |
| 167 | // Calculate the query interval based on the operator's interval |
| 168 | // The interval [d1, d2] means "from d2 ago to d1 ago" |
| 169 | queryInterval, err := te.resolveOperatorInterval(opInterval) |
| 170 | if err != nil { |
| 171 | return nil, err |
| 172 | } |
| 173 | |
| 174 | var solutions []unionfind.UnionFind |
| 175 | |
| 176 | // Query facts that overlap with the query interval |
| 177 | err = te.temporalStore.GetFactsDuring(atom, queryInterval, func(tf factstore.TemporalFact) error { |
| 178 | // Unify the fact with the query atom |
| 179 | newSubst, err := unionfind.UnifyTermsExtend(atom.Args, tf.Atom.Args, subst) |
| 180 | if err != nil { |
| 181 | return nil // No match, continue |
| 182 | } |
| 183 | |
| 184 | // Bind interval variables if present |
| 185 | if interval != nil { |
| 186 | newSubst = te.bindIntervalVariables(*interval, tf.Interval, newSubst) |
| 187 | } |
| 188 | |
| 189 | solutions = append(solutions, newSubst) |
| 190 | return nil |
| 191 | }) |
| 192 | |
| 193 | if err != nil { |
| 194 | return nil, err |
| 195 | } |
| 196 | |
| 197 | return solutions, nil |
| 198 | } |
| 199 | |
| 200 | // evalBoxMinus implements the box-minus operator ([-). |
| 201 | // It returns true if the atom was true CONTINUOUSLY throughout the past interval. |
no test coverage detected