Documentation

Provenance.Algorithms.CompOp

Comparison operator for HAVING enumeration algorithms #

Shared definition used by Provenance.Algorithms.CountEnum, Provenance.Algorithms.SumDP and Provenance.HavingMinMax. The operator parameter is op ∈ {=, ≠, <, ≤, >, ≥}.

inductive CompOp :

Comparison operator, as used by the HAVING enumeration algorithms.

syneq and synne are SQL's IS NOT DISTINCT FROM and IS DISTINCT FROM: they compare values as values, two nulls being the same value, and so are never unknown. Every other comparison is null-strict (CompOp.strict). The distinction is what grouping, partitioning, duplicate elimination and difference need, since they key on values and not on the three-valued equality.

Instances For
    Dependency graph
    @[instance_reducible]
    Equations
    Dependency graph
    Equations
    Instances For
      Dependency graph
      @[instance_reducible]
      Equations
      Dependency graph

      Whether the comparison is null-strict, that is, unknown as soon as an operand is null. All of SQL's comparisons are, except the two syntactic ones.

      Equations
      Instances For
        Dependency graph
        def CompOp.eval {V : Type u_1} [LinearOrder V] :
        CompOp → V → V → Prop

        Semantics of a comparison operator over any linearly ordered value domain (the aggregate values compared by a HAVING predicate; the enumeration algorithms use it at V = ℕ).

        Equations
        Instances For
          Dependency graph
          @[instance_reducible]
          instance instDecidableEval {V : Type u_1} [LinearOrder V] (op : CompOp) (a b : V) :
          Decidable (op.eval a b)
          Equations
          • One or more equations did not get rendered due to their size.
          Dependency graph

          The complementary comparison operator: op.negate holds exactly when op does not. This is how ProvSQL interprets NOT over an aggregate comparison (PostgreSQL's operator negator), with NOT pushed through Boolean combinations by De Morgan duality.

          Equations
          Instances For
            Dependency graph