Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions builtin/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var (
symbols.Contains: {ast.ArgModeInput, ast.ArgModeInput},
symbols.Filter: {ast.ArgModeInput},
symbols.Lt: {ast.ArgModeInput, ast.ArgModeInput},
symbols.Ne: {ast.ArgModeInput, ast.ArgModeInput},
symbols.Le: {ast.ArgModeInput, ast.ArgModeInput},
symbols.Gt: {ast.ArgModeInput, ast.ArgModeInput},
symbols.Ge: {ast.ArgModeInput, ast.ArgModeInput},
Expand Down Expand Up @@ -271,6 +272,11 @@ func Decide(atom ast.Atom, subst *unionfind.UnionFind) (bool, []*unionfind.Union
}
return false, nil, nil

case symbols.Ne.Symbol:
if len(atom.Args) != 2 {
return false, nil, fmt.Errorf("wrong number of arguments for built-in predicate ':ne': %v", atom.Args)
}
return !atom.Args[0].Equals(atom.Args[1]), []*unionfind.UnionFind{subst}, nil
case symbols.Lt.Symbol:
if len(atom.Args) != 2 {
return false, nil, fmt.Errorf("wrong number of arguments for built-in predicate '<': %v", atom.Args)
Expand Down
3 changes: 3 additions & 0 deletions symbols/symbols.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ var (

// Lt is the less-than relation on numbers.
Lt = ast.PredicateSym{":lt", 2}
// Ne is inequality over any two evaluated constants.
Ne = ast.PredicateSym{":ne", 2}

// Le is the less-than-or-equal relation on numbers.
Le = ast.PredicateSym{":le", 2}
Expand Down Expand Up @@ -369,6 +371,7 @@ var (
Filter: NewRelType(BoolType()),
// TODO: support float64
Lt: NewRelType(ast.NumberBound, ast.NumberBound),
Ne: NewRelType(ast.AnyBound, ast.AnyBound),
Le: NewRelType(ast.NumberBound, ast.NumberBound),
Gt: NewRelType(ast.NumberBound, ast.NumberBound),
Ge: NewRelType(ast.NumberBound, ast.NumberBound),
Expand Down