diff --git a/pkg/hir/parser.go b/pkg/hir/parser.go index 6529255..b84c4df 100644 --- a/pkg/hir/parser.go +++ b/pkg/hir/parser.go @@ -435,7 +435,7 @@ func (p *hirParser) parseConstraintDeclaration(elements []sexp.SExp) error { // Vanishing constraints do not have global scope, hence qualified column // accesses are not permitted. p.global = false - attributes, err := p.parseConstraintAttributes(elements[2]) + domain, guard, err := p.parseConstraintAttributes(elements[2]) // Check for error if err != nil { return err @@ -444,6 +444,9 @@ func (p *hirParser) parseConstraintDeclaration(elements []sexp.SExp) error { expr, err := p.translator.Translate(elements[3]) if err != nil { return err + } else if guard != nil { + // if guard != 0 then expr + expr = &IfZero{guard, nil, expr} } // Determine evaluation context of expression. ctx := expr.Context(p.env.schema) @@ -454,16 +457,15 @@ func (p *hirParser) parseConstraintDeclaration(elements []sexp.SExp) error { return p.translator.SyntaxError(elements[3], "empty evaluation context") } - p.env.schema.AddVanishingConstraint(handle, ctx, attributes, expr) + p.env.schema.AddVanishingConstraint(handle, ctx, domain, expr) return nil } -func (p *hirParser) parseConstraintAttributes(attributes sexp.SExp) (domain *int, err error) { - var res *int = nil +func (p *hirParser) parseConstraintAttributes(attributes sexp.SExp) (domain *int, guard Expr, err error) { // Check attribute list is a list if attributes.AsList() == nil { - return nil, p.translator.SyntaxError(attributes, "expected attribute list") + return nil, nil, p.translator.SyntaxError(attributes, "expected attribute list") } // Deconstruct as list attrs := attributes.AsList() @@ -472,21 +474,26 @@ func (p *hirParser) parseConstraintAttributes(attributes sexp.SExp) (domain *int ith := attrs.Get(i) // Check start of attribute if ith.AsSymbol() == nil { - return nil, p.translator.SyntaxError(ith, "malformed attribute") + return nil, nil, p.translator.SyntaxError(ith, "malformed attribute") } // Check what we've got switch ith.AsSymbol().Value { case ":domain": i++ - if res, err = p.parseDomainAttribute(attrs.Get(i)); err != nil { - return nil, err + if domain, err = p.parseDomainAttribute(attrs.Get(i)); err != nil { + return nil, nil, err + } + case ":guard": + i++ + if guard, err = p.translator.Translate(attrs.Get(i)); err != nil { + return nil, nil, err } default: - return nil, p.translator.SyntaxError(ith, "unknown attribute") + return nil, nil, p.translator.SyntaxError(ith, "unknown attribute") } } // Done - return res, nil + return domain, guard, nil } func (p *hirParser) parseDomainAttribute(attribute sexp.SExp) (domain *int, err error) { diff --git a/pkg/test/ir_test.go b/pkg/test/ir_test.go index 082646c..dcdce8f 100644 --- a/pkg/test/ir_test.go +++ b/pkg/test/ir_test.go @@ -248,6 +248,30 @@ func Test_If_09(t *testing.T) { Check(t, "if_09") } +// =================================================================== +// Guards +// =================================================================== + +func Test_Guard_01(t *testing.T) { + Check(t, "guard_01") +} + +func Test_Guard_02(t *testing.T) { + Check(t, "guard_02") +} + +func Test_Guard_03(t *testing.T) { + Check(t, "guard_03") +} + +func Test_Guard_04(t *testing.T) { + Check(t, "guard_04") +} + +func Test_Guard_05(t *testing.T) { + Check(t, "guard_05") +} + // =================================================================== // Column Types // =================================================================== diff --git a/testdata/guard_01.accepts b/testdata/guard_01.accepts new file mode 100644 index 0000000..3bd49e1 --- /dev/null +++ b/testdata/guard_01.accepts @@ -0,0 +1,22 @@ +{ "STAMP": [], "X": [] } +{ "STAMP": [0], "X": [0] } +{ "STAMP": [0], "X": [1] } +{ "STAMP": [0], "X": [2] } +{ "STAMP": [0], "X": [3] } +{ "STAMP": [1], "X": [1] } +{ "STAMP": [1], "X": [2] } +;; +{ "STAMP": [0,0], "X": [0,0] } +{ "STAMP": [0,1], "X": [0,1] } +{ "STAMP": [0,1], "X": [0,2] } +{ "STAMP": [0,2], "X": [0,1] } +{ "STAMP": [0,2], "X": [0,2] } +{ "STAMP": [1,0], "X": [1,0] } +{ "STAMP": [1,0], "X": [2,0] } +{ "STAMP": [2,0], "X": [1,0] } +{ "STAMP": [2,0], "X": [2,0] } +{ "STAMP": [1,0], "X": [1,0] } +{ "STAMP": [1,1], "X": [1,1] } +{ "STAMP": [1,1], "X": [1,2] } +{ "STAMP": [1,2], "X": [1,1] } +{ "STAMP": [1,2], "X": [1,2] } diff --git a/testdata/guard_01.lisp b/testdata/guard_01.lisp new file mode 100644 index 0000000..12bd380 --- /dev/null +++ b/testdata/guard_01.lisp @@ -0,0 +1,3 @@ +(defcolumns STAMP X) +;; STAMP == 0 || X == 1 || X == 2 +(defconstraint c1 (:guard STAMP) (* (- X 1) (- X 2))) diff --git a/testdata/guard_01.rejects b/testdata/guard_01.rejects new file mode 100644 index 0000000..dda350a --- /dev/null +++ b/testdata/guard_01.rejects @@ -0,0 +1,8 @@ +{ "STAMP": [1], "X": [0] } +{ "STAMP": [1], "X": [3] } +{ "STAMP": [2], "X": [0] } +{ "STAMP": [2], "X": [3] } +{ "STAMP": [1,0], "X": [0,0] } +{ "STAMP": [1,1], "X": [0,1] } +{ "STAMP": [1,1], "X": [0,2] } +{ "STAMP": [1,2], "X": [0,1] } diff --git a/testdata/guard_02.accepts b/testdata/guard_02.accepts new file mode 100644 index 0000000..642f648 --- /dev/null +++ b/testdata/guard_02.accepts @@ -0,0 +1,36 @@ +{ "ST": [], "A": [], "B": [] } +{ "ST": [0], "A": [-2], "B": [123] } +{ "ST": [0], "A": [-1], "B": [123] } +{ "ST": [0], "A": [0], "B": [0] } +{ "ST": [0], "A": [1], "B": [123] } +{ "ST": [0], "A": [2], "B": [123] } +{ "ST": [0], "A": [0], "B": [-1] } +{ "ST": [0], "A": [0], "B": [1] } +{ "ST": [0], "A": [0], "B": [2] } +{ "ST": [0,0], "A": [1,0], "B": [-1,-1] } +{ "ST": [0,0], "A": [1,0], "B": [1,1] } +{ "ST": [0,0], "A": [1,0], "B": [2,2] } +{ "ST": [0,0], "A": [0,0], "B": [0,0] } +{ "ST": [0,0], "A": [1,0], "B": [123,0] } +{ "ST": [0,0], "A": [0,1], "B": [0,123] } +{ "ST": [0,0], "A": [1,1], "B": [123,234] } +;; +{ "ST": [], "A": [], "B": [] } +{ "ST": [1], "A": [-2], "B": [123] } +{ "ST": [1], "A": [-1], "B": [123] } +{ "ST": [1], "A": [0], "B": [0] } +{ "ST": [1], "A": [1], "B": [123] } +{ "ST": [1], "A": [2], "B": [123] } +{ "ST": [0,1], "A": [0,0], "B": [0,0] } +{ "ST": [0,1], "A": [1,0], "B": [123,0] } +{ "ST": [0,1], "A": [0,1], "B": [0,123] } +{ "ST": [0,1], "A": [1,1], "B": [123,234] } +{ "ST": [1,0], "A": [0,0], "B": [0,0] } +{ "ST": [1,0], "A": [1,0], "B": [123,0] } +{ "ST": [1,0], "A": [0,1], "B": [0,123] } +{ "ST": [1,0], "A": [1,1], "B": [123,234] } +{ "ST": [1,1], "A": [0,0], "B": [0,0] } +{ "ST": [1,1], "A": [1,0], "B": [123,0] } +{ "ST": [1,1], "A": [0,1], "B": [0,123] } +{ "ST": [1,1], "A": [1,1], "B": [123,234] } +;; diff --git a/testdata/guard_02.lisp b/testdata/guard_02.lisp new file mode 100644 index 0000000..65de893 --- /dev/null +++ b/testdata/guard_02.lisp @@ -0,0 +1,3 @@ +(defcolumns ST A B) +;; STAMP == 0 || X == 1 || X == 2 +(defconstraint c1 (:guard ST) (if A B)) diff --git a/testdata/guard_02.rejects b/testdata/guard_02.rejects new file mode 100644 index 0000000..ff5dc4e --- /dev/null +++ b/testdata/guard_02.rejects @@ -0,0 +1,9 @@ +{ "ST": [1], "A": [0], "B": [-1] } +{ "ST": [1], "A": [0], "B": [1] } +{ "ST": [1], "A": [0], "B": [2] } +{ "ST": [0,1], "A": [1,0], "B": [-1,-1] } +{ "ST": [0,1], "A": [1,0], "B": [1,1] } +{ "ST": [0,1], "A": [1,0], "B": [2,2] } +{ "ST": [1,1], "A": [1,0], "B": [-1,-1] } +{ "ST": [1,1], "A": [1,0], "B": [1,1] } +{ "ST": [1,1], "A": [1,0], "B": [2,2] } diff --git a/testdata/guard_03.accepts b/testdata/guard_03.accepts new file mode 100644 index 0000000..67d9e60 --- /dev/null +++ b/testdata/guard_03.accepts @@ -0,0 +1,29 @@ +{ "ST": [], "A": [], "B": [] } +{ "ST": [0], "A": [0], "B": [-1] } +{ "ST": [0], "A": [0], "B": [1] } +{ "ST": [0], "A": [0], "B": [2] } +{ "ST": [1], "A": [0], "B": [-1] } +{ "ST": [1], "A": [0], "B": [1] } +{ "ST": [1], "A": [0], "B": [2] } +{ "ST": [0,0], "A": [1,0], "B": [0,-1] } +{ "ST": [0,0], "A": [1,0], "B": [0,1] } +{ "ST": [0,0], "A": [1,0], "B": [0,2] } +{ "ST": [1,0], "A": [1,0], "B": [0,-1] } +{ "ST": [1,0], "A": [1,0], "B": [0,1] } +{ "ST": [1,0], "A": [1,0], "B": [0,2] } +{ "ST": [0,1], "A": [1,0], "B": [0,-1] } +{ "ST": [0,1], "A": [1,0], "B": [0,1] } +{ "ST": [0,1], "A": [1,0], "B": [0,2] } +{ "ST": [1,1], "A": [1,0], "B": [0,-1] } +{ "ST": [1,1], "A": [1,0], "B": [0,1] } +{ "ST": [1,1], "A": [1,0], "B": [0,2] } +;; +{ "ST": [0], "A": [-2], "B": [123] } +{ "ST": [0], "A": [-1], "B": [123] } +{ "ST": [0], "A": [1], "B": [1] } +{ "ST": [0], "A": [1], "B": [123] } +{ "ST": [0], "A": [2], "B": [123] } +{ "ST": [0,0], "A": [0,1], "B": [0,1] } +{ "ST": [0,0], "A": [1,0], "B": [123,0] } +{ "ST": [0,0], "A": [0,1], "B": [0,123] } +{ "ST": [0,0], "A": [1,1], "B": [123,234] } diff --git a/testdata/guard_03.lisp b/testdata/guard_03.lisp new file mode 100644 index 0000000..7a3ff74 --- /dev/null +++ b/testdata/guard_03.lisp @@ -0,0 +1,2 @@ +(defcolumns ST A B) +(defconstraint c1 (:guard ST) (ifnot A B)) diff --git a/testdata/guard_03.rejects b/testdata/guard_03.rejects new file mode 100644 index 0000000..8f2361e --- /dev/null +++ b/testdata/guard_03.rejects @@ -0,0 +1,9 @@ +{ "ST": [1], "A": [-2], "B": [123] } +{ "ST": [1], "A": [-1], "B": [123] } +{ "ST": [1], "A": [1], "B": [1] } +{ "ST": [1], "A": [1], "B": [123] } +{ "ST": [1], "A": [2], "B": [123] } +{ "ST": [1,1], "A": [0,1], "B": [0,1] } +{ "ST": [1,1], "A": [1,0], "B": [123,0] } +{ "ST": [1,1], "A": [0,1], "B": [0,123] } +{ "ST": [1,1], "A": [1,1], "B": [123,234] } diff --git a/testdata/guard_04.accepts b/testdata/guard_04.accepts new file mode 100644 index 0000000..be5bd6f --- /dev/null +++ b/testdata/guard_04.accepts @@ -0,0 +1,46 @@ +{ "ST": [], "A": [], "B": [], "C": [] } +{ "ST": [0], "A": [-2], "B": [234], "C": [0] } +{ "ST": [0], "A": [-1], "B": [123], "C": [0] } +{ "ST": [0], "A": [0], "B": [0], "C": [123] } +{ "ST": [0], "A": [0], "B": [0], "C": [234] } +{ "ST": [0], "A": [1], "B": [123], "C": [0] } +{ "ST": [0], "A": [2], "B": [234], "C": [0] } +;; +{ "ST": [1], "A": [-2], "B": [234], "C": [0] } +{ "ST": [1], "A": [-1], "B": [123], "C": [0] } +{ "ST": [1], "A": [0], "B": [0], "C": [123] } +{ "ST": [1], "A": [0], "B": [0], "C": [234] } +{ "ST": [1], "A": [1], "B": [123], "C": [0] } +{ "ST": [1], "A": [2], "B": [234], "C": [0] } +;; +{ "ST": [0], "A": [0], "B": [-2], "C": [0] } +{ "ST": [0], "A": [0], "B": [-1], "C": [0] } +{ "ST": [0], "A": [0], "B": [1], "C": [0] } +{ "ST": [0], "A": [0], "B": [2], "C": [0] } +{ "ST": [0], "A": [0], "B": [-2], "C": [-1] } +{ "ST": [0], "A": [0], "B": [-1], "C": [1] } +{ "ST": [0], "A": [0], "B": [1], "C": [2] } +{ "ST": [0], "A": [0], "B": [2], "C": [-2] } +{ "ST": [0], "A": [1], "B": [0], "C": [-2] } +{ "ST": [0], "A": [1], "B": [0], "C": [-1] } +{ "ST": [0], "A": [1], "B": [0], "C": [1] } +{ "ST": [0], "A": [1], "B": [0], "C": [2] } +{ "ST": [0], "A": [1], "B": [-2], "C": [-2] } +{ "ST": [0], "A": [1], "B": [-1], "C": [-1] } +{ "ST": [0], "A": [1], "B": [1], "C": [1] } +{ "ST": [0], "A": [1], "B": [1], "C": [2] } +{ "ST": [0], "A": [2], "B": [0], "C": [-2] } +{ "ST": [0], "A": [2], "B": [0], "C": [-1] } +{ "ST": [0], "A": [2], "B": [0], "C": [1] } +{ "ST": [0], "A": [2], "B": [0], "C": [2] } +{ "ST": [0], "A": [2], "B": [-2], "C": [-2] } +{ "ST": [0], "A": [2], "B": [-1], "C": [-1] } +{ "ST": [0], "A": [2], "B": [1], "C": [1] } +{ "ST": [0], "A": [2], "B": [1], "C": [2] } +;; +{ "ST": [0,0,0,0,0], "A": [-2,-1,0,1,2], "B": [234,123,0,456,789], "C": [0,0,123,0,0]} +{ "ST": [1,0,0,0,0], "A": [-2,-1,0,1,2], "B": [234,123,0,456,789], "C": [0,0,123,0,0]} +{ "ST": [0,1,0,0,0], "A": [-2,-1,0,1,2], "B": [234,123,0,456,789], "C": [0,0,123,0,0]} +{ "ST": [0,0,1,0,0], "A": [-2,-1,0,1,2], "B": [234,123,0,456,789], "C": [0,0,123,0,0]} +{ "ST": [0,0,0,1,0], "A": [-2,-1,0,1,2], "B": [234,123,0,456,789], "C": [0,0,123,0,0]} +{ "ST": [0,0,0,0,1], "A": [-2,-1,0,1,2], "B": [234,123,0,456,789], "C": [0,0,123,0,0]} diff --git a/testdata/guard_04.lisp b/testdata/guard_04.lisp new file mode 100644 index 0000000..50b3af4 --- /dev/null +++ b/testdata/guard_04.lisp @@ -0,0 +1,2 @@ +(defcolumns ST A B C) +(defconstraint c1 (:guard ST) (if A B C)) diff --git a/testdata/guard_04.rejects b/testdata/guard_04.rejects new file mode 100644 index 0000000..fcdaa7f --- /dev/null +++ b/testdata/guard_04.rejects @@ -0,0 +1,24 @@ +{ "ST": [1], "A": [0], "B": [-2], "C": [0] } +{ "ST": [1], "A": [0], "B": [-1], "C": [0] } +{ "ST": [1], "A": [0], "B": [1], "C": [0] } +{ "ST": [1], "A": [0], "B": [2], "C": [0] } +{ "ST": [1], "A": [0], "B": [-2], "C": [-1] } +{ "ST": [1], "A": [0], "B": [-1], "C": [1] } +{ "ST": [1], "A": [0], "B": [1], "C": [2] } +{ "ST": [1], "A": [0], "B": [2], "C": [-2] } +{ "ST": [1], "A": [1], "B": [0], "C": [-2] } +{ "ST": [1], "A": [1], "B": [0], "C": [-1] } +{ "ST": [1], "A": [1], "B": [0], "C": [1] } +{ "ST": [1], "A": [1], "B": [0], "C": [2] } +{ "ST": [1], "A": [1], "B": [-2], "C": [-2] } +{ "ST": [1], "A": [1], "B": [-1], "C": [-1] } +{ "ST": [1], "A": [1], "B": [1], "C": [1] } +{ "ST": [1], "A": [1], "B": [1], "C": [2] } +{ "ST": [1], "A": [2], "B": [0], "C": [-2] } +{ "ST": [1], "A": [2], "B": [0], "C": [-1] } +{ "ST": [1], "A": [2], "B": [0], "C": [1] } +{ "ST": [1], "A": [2], "B": [0], "C": [2] } +{ "ST": [1], "A": [2], "B": [-2], "C": [-2] } +{ "ST": [1], "A": [2], "B": [-1], "C": [-1] } +{ "ST": [1], "A": [2], "B": [1], "C": [1] } +{ "ST": [1], "A": [2], "B": [1], "C": [2] } diff --git a/testdata/guard_05.accepts b/testdata/guard_05.accepts new file mode 100644 index 0000000..3b80f80 --- /dev/null +++ b/testdata/guard_05.accepts @@ -0,0 +1,176 @@ +{"ST": [0], "X": [0], "Y": [0], "Z": [0]} +{"ST": [0], "X": [0], "Y": [1], "Z": [16]} +{"ST": [0], "X": [0], "Y": [2], "Z": [16]} +{"ST": [0], "X": [0], "Y": [3], "Z": [16]} +{"ST": [0], "X": [1], "Y": [0], "Z": [0]} +{"ST": [0], "X": [1], "Y": [0], "Z": [1]} +{"ST": [0], "X": [1], "Y": [0], "Z": [2]} +{"ST": [0], "X": [1], "Y": [0], "Z": [0]} +{"ST": [0], "X": [1], "Y": [1], "Z": [0]} +{"ST": [0], "X": [1], "Y": [2], "Z": [0]} +{"ST": [0], "X": [1], "Y": [1], "Z": [1]} +{"ST": [0], "X": [1], "Y": [2], "Z": [1]} +{"ST": [0], "X": [1], "Y": [1], "Z": [2]} +{"ST": [0], "X": [1], "Y": [2], "Z": [2]} +{"ST": [0], "X": [2], "Y": [0], "Z": [0]} +{"ST": [0], "X": [2], "Y": [0], "Z": [1]} +{"ST": [0], "X": [2], "Y": [0], "Z": [2]} +{"ST": [0], "X": [2], "Y": [0], "Z": [0]} +{"ST": [0], "X": [2], "Y": [1], "Z": [0]} +{"ST": [0], "X": [2], "Y": [2], "Z": [0]} +{"ST": [0], "X": [2], "Y": [1], "Z": [1]} +{"ST": [0], "X": [2], "Y": [2], "Z": [1]} +{"ST": [0], "X": [2], "Y": [1], "Z": [2]} +{"ST": [0], "X": [2], "Y": [2], "Z": [2]} +;; +{"ST": [1], "X": [0], "Y": [0], "Z": [0]} +{"ST": [1], "X": [0], "Y": [1], "Z": [16]} +{"ST": [1], "X": [0], "Y": [2], "Z": [16]} +{"ST": [1], "X": [0], "Y": [3], "Z": [16]} +{"ST": [1], "X": [1], "Y": [0], "Z": [0]} +{"ST": [1], "X": [1], "Y": [0], "Z": [1]} +{"ST": [1], "X": [1], "Y": [0], "Z": [2]} +{"ST": [1], "X": [1], "Y": [0], "Z": [0]} +{"ST": [1], "X": [1], "Y": [1], "Z": [0]} +{"ST": [1], "X": [1], "Y": [2], "Z": [0]} +{"ST": [1], "X": [1], "Y": [1], "Z": [1]} +{"ST": [1], "X": [1], "Y": [2], "Z": [1]} +{"ST": [1], "X": [1], "Y": [1], "Z": [2]} +{"ST": [1], "X": [1], "Y": [2], "Z": [2]} +{"ST": [1], "X": [2], "Y": [0], "Z": [0]} +{"ST": [1], "X": [2], "Y": [0], "Z": [1]} +{"ST": [1], "X": [2], "Y": [0], "Z": [2]} +{"ST": [1], "X": [2], "Y": [0], "Z": [0]} +{"ST": [1], "X": [2], "Y": [1], "Z": [0]} +{"ST": [1], "X": [2], "Y": [2], "Z": [0]} +{"ST": [1], "X": [2], "Y": [1], "Z": [1]} +{"ST": [1], "X": [2], "Y": [2], "Z": [1]} +{"ST": [1], "X": [2], "Y": [1], "Z": [2]} +{"ST": [1], "X": [2], "Y": [2], "Z": [2]} +;; +{"ST": [0], "X": [0], "Y": [0], "Z": [1]} +{"ST": [0], "X": [0], "Y": [0], "Z": [2]} +{"ST": [0], "X": [0], "Y": [0], "Z": [3]} +{"ST": [0], "X": [0], "Y": [0], "Z": [4]} +{"ST": [0], "X": [0], "Y": [0], "Z": [16]} +{"ST": [0], "X": [0], "Y": [1], "Z": [0]} +{"ST": [0], "X": [0], "Y": [1], "Z": [1]} +{"ST": [0], "X": [0], "Y": [1], "Z": [2]} +{"ST": [0], "X": [0], "Y": [1], "Z": [3]} +{"ST": [0], "X": [0], "Y": [1], "Z": [4]} +{"ST": [0], "X": [0], "Y": [2], "Z": [0]} +{"ST": [0], "X": [0], "Y": [2], "Z": [1]} +{"ST": [0], "X": [0], "Y": [2], "Z": [2]} +{"ST": [0], "X": [0], "Y": [2], "Z": [3]} +{"ST": [0], "X": [0], "Y": [2], "Z": [4]} +{"ST": [0], "X": [0], "Y": [3], "Z": [0]} +{"ST": [0], "X": [0], "Y": [3], "Z": [1]} +{"ST": [0], "X": [0], "Y": [3], "Z": [2]} +{"ST": [0], "X": [0], "Y": [3], "Z": [3]} +{"ST": [0], "X": [0], "Y": [3], "Z": [4]} +;; +{"ST": [0,0], "X": [0,0], "Y": [0,0], "Z": [0,0]} +{"ST": [0,0], "X": [0,0], "Y": [1,0], "Z": [16,0]} +{"ST": [0,0], "X": [0,0], "Y": [0,1], "Z": [0,16]} +{"ST": [0,0], "X": [0,0], "Y": [1,1], "Z": [16,16]} +{"ST": [0,0], "X": [0,0], "Y": [2,0], "Z": [16,0]} +{"ST": [0,0], "X": [0,0], "Y": [0,2], "Z": [0,16]} +{"ST": [0,0], "X": [0,0], "Y": [2,2], "Z": [16,16]} +{"ST": [0,0], "X": [0,0], "Y": [3,0], "Z": [16,0]} +{"ST": [0,0], "X": [0,0], "Y": [0,3], "Z": [0,16]} +{"ST": [0,0], "X": [0,0], "Y": [3,3], "Z": [16,16]} +{"ST": [0,0], "X": [0,1], "Y": [0,0], "Z": [0,55]} +{"ST": [0,0], "X": [0,1], "Y": [1,0], "Z": [16,55]} +{"ST": [0,0], "X": [1,0], "Y": [0,0], "Z": [12,0]} +{"ST": [0,0], "X": [1,0], "Y": [0,1], "Z": [12,16]} +{"ST": [0,0], "X": [1,1], "Y": [0,0], "Z": [12,72]} +;; +{"ST": [1,0], "X": [0,0], "Y": [0,0], "Z": [0,0]} +{"ST": [1,0], "X": [0,0], "Y": [1,0], "Z": [16,0]} +{"ST": [1,0], "X": [0,0], "Y": [0,1], "Z": [0,16]} +{"ST": [1,0], "X": [0,0], "Y": [1,1], "Z": [16,16]} +{"ST": [1,0], "X": [0,0], "Y": [2,0], "Z": [16,0]} +{"ST": [1,0], "X": [0,0], "Y": [0,2], "Z": [0,16]} +{"ST": [1,0], "X": [0,0], "Y": [2,2], "Z": [16,16]} +{"ST": [1,0], "X": [0,0], "Y": [3,0], "Z": [16,0]} +{"ST": [1,0], "X": [0,0], "Y": [0,3], "Z": [0,16]} +{"ST": [1,0], "X": [0,0], "Y": [3,3], "Z": [16,16]} +{"ST": [1,0], "X": [0,1], "Y": [0,0], "Z": [0,55]} +{"ST": [1,0], "X": [0,1], "Y": [1,0], "Z": [16,55]} +{"ST": [1,0], "X": [1,0], "Y": [0,0], "Z": [12,0]} +{"ST": [1,0], "X": [1,0], "Y": [0,1], "Z": [12,16]} +{"ST": [1,0], "X": [1,1], "Y": [0,0], "Z": [12,72]} +;; +{"ST": [0,1], "X": [0,0], "Y": [0,0], "Z": [0,0]} +{"ST": [0,1], "X": [0,0], "Y": [1,0], "Z": [16,0]} +{"ST": [0,1], "X": [0,0], "Y": [0,1], "Z": [0,16]} +{"ST": [0,1], "X": [0,0], "Y": [1,1], "Z": [16,16]} +{"ST": [0,1], "X": [0,0], "Y": [2,0], "Z": [16,0]} +{"ST": [0,1], "X": [0,0], "Y": [0,2], "Z": [0,16]} +{"ST": [0,1], "X": [0,0], "Y": [2,2], "Z": [16,16]} +{"ST": [0,1], "X": [0,0], "Y": [3,0], "Z": [16,0]} +{"ST": [0,1], "X": [0,0], "Y": [0,3], "Z": [0,16]} +{"ST": [0,1], "X": [0,0], "Y": [3,3], "Z": [16,16]} +{"ST": [0,1], "X": [0,1], "Y": [0,0], "Z": [0,55]} +{"ST": [0,1], "X": [0,1], "Y": [1,0], "Z": [16,55]} +{"ST": [0,1], "X": [1,0], "Y": [0,0], "Z": [12,0]} +{"ST": [0,1], "X": [1,0], "Y": [0,1], "Z": [12,16]} +{"ST": [0,1], "X": [1,1], "Y": [0,0], "Z": [12,72]} +;; +{"ST": [1,1], "X": [0,0], "Y": [0,0], "Z": [0,0]} +{"ST": [1,1], "X": [0,0], "Y": [1,0], "Z": [16,0]} +{"ST": [1,1], "X": [0,0], "Y": [0,1], "Z": [0,16]} +{"ST": [1,1], "X": [0,0], "Y": [1,1], "Z": [16,16]} +{"ST": [1,1], "X": [0,0], "Y": [2,0], "Z": [16,0]} +{"ST": [1,1], "X": [0,0], "Y": [0,2], "Z": [0,16]} +{"ST": [1,1], "X": [0,0], "Y": [2,2], "Z": [16,16]} +{"ST": [1,1], "X": [0,0], "Y": [3,0], "Z": [16,0]} +{"ST": [1,1], "X": [0,0], "Y": [0,3], "Z": [0,16]} +{"ST": [1,1], "X": [0,0], "Y": [3,3], "Z": [16,16]} +{"ST": [1,1], "X": [0,1], "Y": [0,0], "Z": [0,55]} +{"ST": [1,1], "X": [0,1], "Y": [1,0], "Z": [16,55]} +{"ST": [1,1], "X": [1,0], "Y": [0,0], "Z": [12,0]} +{"ST": [1,1], "X": [1,0], "Y": [0,1], "Z": [12,16]} +{"ST": [1,1], "X": [1,1], "Y": [0,0], "Z": [12,72]} +;; +{"ST": [0,0], "X": [0,0], "Y": [0,0], "Z": [1,0]} +{"ST": [0,0], "X": [0,0], "Y": [0,0], "Z": [0,1]} +{"ST": [0,0], "X": [0,0], "Y": [0,0], "Z": [1,1]} +{"ST": [0,0], "X": [0,0], "Y": [0,1], "Z": [1,0]} +{"ST": [0,0], "X": [0,0], "Y": [1,0], "Z": [0,1]} +{"ST": [0,0], "X": [0,0], "Y": [1,1], "Z": [1,1]} +{"ST": [0,0], "X": [0,0], "Y": [0,0], "Z": [3,0]} +{"ST": [0,0], "X": [0,0], "Y": [0,0], "Z": [1,3]} +{"ST": [0,0], "X": [0,0], "Y": [0,0], "Z": [3,1]} +{"ST": [0,0], "X": [0,0], "Y": [0,0], "Z": [1,1]} +{"ST": [0,0], "X": [0,0], "Y": [0,1], "Z": [1,16]} +{"ST": [0,0], "X": [0,0], "Y": [1,0], "Z": [16,1]} +{"ST": [0,0], "X": [0,0], "Y": [1,1], "Z": [1,1]} +{"ST": [0,0], "X": [1,0], "Y": [0,0], "Z": [0,3]} +{"ST": [0,0], "X": [1,0], "Y": [0,0], "Z": [1,3]} +{"ST": [0,0], "X": [1,0], "Y": [0,0], "Z": [0,1]} +{"ST": [0,0], "X": [1,0], "Y": [0,0], "Z": [1,1]} +{"ST": [0,0], "X": [1,0], "Y": [0,1], "Z": [1,0]} +{"ST": [0,0], "X": [1,0], "Y": [1,0], "Z": [0,1]} +{"ST": [0,0], "X": [1,0], "Y": [1,1], "Z": [1,1]} +{"ST": [0,0], "X": [1,0], "Y": [0,0], "Z": [3,3]} +{"ST": [0,0], "X": [1,0], "Y": [0,0], "Z": [1,16]} +{"ST": [0,0], "X": [1,0], "Y": [0,0], "Z": [3,1]} +{"ST": [0,0], "X": [1,0], "Y": [0,0], "Z": [1,1]} +{"ST": [0,0], "X": [1,0], "Y": [0,1], "Z": [1,3]} +{"ST": [0,0], "X": [1,0], "Y": [1,0], "Z": [16,1]} +{"ST": [0,0], "X": [1,0], "Y": [1,1], "Z": [1,1]} +{"ST": [0,0], "X": [0,1], "Y": [0,0], "Z": [3,0]} +{"ST": [0,0], "X": [0,1], "Y": [0,0], "Z": [1,3]} +{"ST": [0,0], "X": [0,1], "Y": [0,0], "Z": [3,1]} +{"ST": [0,0], "X": [0,1], "Y": [0,0], "Z": [1,1]} +{"ST": [0,0], "X": [0,1], "Y": [0,1], "Z": [1,0]} +{"ST": [0,0], "X": [0,1], "Y": [1,0], "Z": [0,1]} +{"ST": [0,0], "X": [0,1], "Y": [1,1], "Z": [1,1]} +{"ST": [0,0], "X": [0,1], "Y": [0,0], "Z": [16,0]} +{"ST": [0,0], "X": [0,1], "Y": [0,0], "Z": [1,3]} +{"ST": [0,0], "X": [0,1], "Y": [0,0], "Z": [16,1]} +{"ST": [0,0], "X": [0,1], "Y": [0,0], "Z": [1,1]} +{"ST": [0,0], "X": [0,1], "Y": [0,1], "Z": [1,16]} +{"ST": [0,0], "X": [0,1], "Y": [1,0], "Z": [3,1]} +{"ST": [0,0], "X": [0,1], "Y": [1,1], "Z": [1,1]} diff --git a/testdata/guard_05.lisp b/testdata/guard_05.lisp new file mode 100644 index 0000000..3dfc02e --- /dev/null +++ b/testdata/guard_05.lisp @@ -0,0 +1,2 @@ +(defcolumns ST X Y Z) +(defconstraint test (:guard ST) (if X (- Z (if Y 0 16)))) diff --git a/testdata/guard_05.rejects b/testdata/guard_05.rejects new file mode 100644 index 0000000..76accec --- /dev/null +++ b/testdata/guard_05.rejects @@ -0,0 +1,62 @@ +{"ST": [1], "X": [0], "Y": [0], "Z": [1]} +{"ST": [1], "X": [0], "Y": [0], "Z": [2]} +{"ST": [1], "X": [0], "Y": [0], "Z": [3]} +{"ST": [1], "X": [0], "Y": [0], "Z": [4]} +{"ST": [1], "X": [0], "Y": [0], "Z": [16]} +{"ST": [1], "X": [0], "Y": [1], "Z": [0]} +{"ST": [1], "X": [0], "Y": [1], "Z": [1]} +{"ST": [1], "X": [0], "Y": [1], "Z": [2]} +{"ST": [1], "X": [0], "Y": [1], "Z": [3]} +{"ST": [1], "X": [0], "Y": [1], "Z": [4]} +{"ST": [1], "X": [0], "Y": [2], "Z": [0]} +{"ST": [1], "X": [0], "Y": [2], "Z": [1]} +{"ST": [1], "X": [0], "Y": [2], "Z": [2]} +{"ST": [1], "X": [0], "Y": [2], "Z": [3]} +{"ST": [1], "X": [0], "Y": [2], "Z": [4]} +{"ST": [1], "X": [0], "Y": [3], "Z": [0]} +{"ST": [1], "X": [0], "Y": [3], "Z": [1]} +{"ST": [1], "X": [0], "Y": [3], "Z": [2]} +{"ST": [1], "X": [0], "Y": [3], "Z": [3]} +{"ST": [1], "X": [0], "Y": [3], "Z": [4]} +;; +{"ST": [1,1], "X": [0,0], "Y": [0,0], "Z": [1,0]} +{"ST": [1,1], "X": [0,0], "Y": [0,0], "Z": [0,1]} +{"ST": [1,1], "X": [0,0], "Y": [0,0], "Z": [1,1]} +{"ST": [1,1], "X": [0,0], "Y": [0,1], "Z": [1,0]} +{"ST": [1,1], "X": [0,0], "Y": [1,0], "Z": [0,1]} +{"ST": [1,1], "X": [0,0], "Y": [1,1], "Z": [1,1]} +{"ST": [1,1], "X": [0,0], "Y": [0,0], "Z": [3,0]} +{"ST": [1,1], "X": [0,0], "Y": [0,0], "Z": [1,3]} +{"ST": [1,1], "X": [0,0], "Y": [0,0], "Z": [3,1]} +{"ST": [1,1], "X": [0,0], "Y": [0,0], "Z": [1,1]} +{"ST": [1,1], "X": [0,0], "Y": [0,1], "Z": [1,16]} +{"ST": [1,1], "X": [0,0], "Y": [1,0], "Z": [16,1]} +{"ST": [1,1], "X": [0,0], "Y": [1,1], "Z": [1,1]} +{"ST": [1,1], "X": [1,0], "Y": [0,0], "Z": [0,3]} +{"ST": [1,1], "X": [1,0], "Y": [0,0], "Z": [1,3]} +{"ST": [1,1], "X": [1,0], "Y": [0,0], "Z": [0,1]} +{"ST": [1,1], "X": [1,0], "Y": [0,0], "Z": [1,1]} +{"ST": [1,1], "X": [1,0], "Y": [0,1], "Z": [1,0]} +{"ST": [1,1], "X": [1,0], "Y": [1,0], "Z": [0,1]} +{"ST": [1,1], "X": [1,0], "Y": [1,1], "Z": [1,1]} +{"ST": [1,1], "X": [1,0], "Y": [0,0], "Z": [3,3]} +{"ST": [1,1], "X": [1,0], "Y": [0,0], "Z": [1,16]} +{"ST": [1,1], "X": [1,0], "Y": [0,0], "Z": [3,1]} +{"ST": [1,1], "X": [1,0], "Y": [0,0], "Z": [1,1]} +{"ST": [1,1], "X": [1,0], "Y": [0,1], "Z": [1,3]} +{"ST": [1,1], "X": [1,0], "Y": [1,0], "Z": [16,1]} +{"ST": [1,1], "X": [1,0], "Y": [1,1], "Z": [1,1]} +{"ST": [1,1], "X": [0,1], "Y": [0,0], "Z": [3,0]} +{"ST": [1,1], "X": [0,1], "Y": [0,0], "Z": [1,3]} +{"ST": [1,1], "X": [0,1], "Y": [0,0], "Z": [3,1]} +{"ST": [1,1], "X": [0,1], "Y": [0,0], "Z": [1,1]} +{"ST": [1,1], "X": [0,1], "Y": [0,1], "Z": [1,0]} +{"ST": [1,1], "X": [0,1], "Y": [1,0], "Z": [0,1]} +{"ST": [1,1], "X": [0,1], "Y": [1,1], "Z": [1,1]} +{"ST": [1,1], "X": [0,1], "Y": [0,0], "Z": [16,0]} +{"ST": [1,1], "X": [0,1], "Y": [0,0], "Z": [1,3]} +{"ST": [1,1], "X": [0,1], "Y": [0,0], "Z": [16,1]} +{"ST": [1,1], "X": [0,1], "Y": [0,0], "Z": [1,1]} +{"ST": [1,1], "X": [0,1], "Y": [0,1], "Z": [1,16]} +{"ST": [1,1], "X": [0,1], "Y": [1,0], "Z": [3,1]} +{"ST": [1,1], "X": [0,1], "Y": [1,1], "Z": [1,1]}