Pairs of conjunctive queries and containment

Lax420092.QueryPairs · concepts/Lax420092/QueryPairs.lean · lax-420092

definition

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Natural Language Statement

    Definition

    An instance of containment is a pair of Boolean conjunctive queries over a shared universe: unary relations mark the variables of the left and of the right query, binary relations record their atoms, and the other elements are shared constants. The left query is contained in the right one when every database, over any universe and any denotation of the constants, that satisfies the left query satisfies the right one. CQContainment is the decision problem of the structures isomorphic to a pair whose left query is contained in the right one.

    Concept map
    9 concepts; 8 descendants hidden
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    Lean source view on GitHub

    1import Mathlib.Tactic.FinCases
    2import Mathlib.ModelTheory.Order
    3import Mathlib.ModelTheory.Semantics
    4import Mathlib.ModelTheory.Complexity
    5import Mathlib.Data.Set.Finite.Lemmas
    6import Mathlib.Order.PiLex
    7import Mathlib.Data.Prod.Lex
    8import Mathlib.Data.Fintype.EquivFin
    9import Mathlib.Logic.Equiv.Fin.Basic
    10import Mathlib.Data.Finite.Sigma
    11import Mathlib.Data.Fintype.Lattice
    12import Mathlib.ModelTheory.Syntax
    13import Mathlib.ModelTheory.Graph
    14import Mathlib.Combinatorics.SimpleGraph.Coloring.Vertex
    15import Mathlib.SetTheory.Cardinal.Finite
    16import Lax904597.Classes
    17import Lax799700.Problems
    18import Lax420092.Evaluation
    19
    20/-!
    21---
    22title: Pairs of conjunctive queries and containment
    23type: definition
    24---
    25An instance of containment is a pair of Boolean conjunctive queries over a
    26shared universe: unary relations mark the variables of the left and of the
    27right query, binary relations record their atoms, and the other elements
    28are shared constants. The left query is contained in the right one when
    29every database, over any universe and any denotation of the constants, that
    30satisfies the left query satisfies the right one. CQContainment is the
    31decision problem of the structures isomorphic to a pair whose left query is
    32contained in the right one.
    33-/
    34
    35namespace Lax420092.QueryPairs
    36
    37open Lax420092.Evaluation
    38
    39open FirstOrder
    40
    41open FirstOrder.Language
    42
    43/-- The relation symbols of the language. -/
    44inductive queryPairRel : ℕ → Type where
    45/-- `leftVar x`: the element `x` is a variable of the left query. -/
    46 | leftVar : queryPairRel 1
    47/-- `rightVar x`: the element `x` is a variable of the right query. -/
    48 | rightVar : queryPairRel 1
    49/-- `leftAtom x y`: the left query contains the atom `E(x, y)`. -/
    50 | leftAtom : queryPairRel 2
    51/-- `rightAtom x y`: the right query contains the atom `E(x, y)`. -/
    52 | rightAtom : queryPairRel 2
    53 deriving DecidableEq
    54
    55/-- The relational language of pairs of conjunctive queries over a shared
    56universe of variables and constants. -/
    57def queryPair : FirstOrder.Language :=
    58 ⟨fun _ => Empty, queryPairRel⟩
    59
    60instance instIsRelationalQueryPair : FirstOrder.Language.IsRelational queryPair := fun _ =>
    61 (inferInstance : IsEmpty Empty)
    62
    63/-- `leftVar x`: the element `x` is a variable of the left query. -/
    64abbrev qpLeftVar : queryPair.Relations 1 :=
    65 .leftVar
    66
    67/-- `rightVar x`: the element `x` is a variable of the right query. -/
    68abbrev qpRightVar : queryPair.Relations 1 :=
    69 .rightVar
    70
    71/-- `leftAtom x y`: the left query contains the atom `E(x, y)`. -/
    72abbrev qpLeftAtom : queryPair.Relations 2 :=
    73 .leftAtom
    74
    75/-- `rightAtom x y`: the right query contains the atom `E(x, y)`. -/
    76abbrev qpRightAtom : queryPair.Relations 2 :=
    77 .rightAtom
    78
    79open FirstOrder
    80
    81open Language Structure BoundedFormula
    82
    83section PairShorthands
    84
    85variable {A : Type} [queryPair.Structure A]
    86
    87/-- `x` is a variable of the left query. -/
    88def LVar (x : A) : Prop := RelMap qpLeftVar ![x]
    89
    90/-- `x` is a variable of the right query. -/
    91def RVar (x : A) : Prop := RelMap qpRightVar ![x]
    92
    93/-- `E(x, y)` is an atom of the left query. -/
    94def LAtom (x y : A) : Prop := RelMap qpLeftAtom ![x, y]
    95
    96/-- `E(x, y)` is an atom of the right query. -/
    97def RAtom (x y : A) : Prop := RelMap qpRightAtom ![x, y]
    98
    99/-- `x` is a variable of either query; the non-`PairVar` elements are the
    100shared constants, whose denotation every database fixes. -/
    101def PairVar (x : A) : Prop := LVar x ∨ RVar x
    102
    103end PairShorthands
    104
    105/-- The left query is contained in the right one: every database (over any
    106universe, with any interpretation of the constants) satisfying the left query
    107satisfies the right query. -/
    108def QueryContained (A : Type) [queryPair.Structure A] : Prop :=
    109 ∀ (U : Type) (F : U → U → Prop) (ι : A → U),
    110 SatisfiedIn (PairVar (A := A)) (LAtom (A := A)) F ι →
    111 SatisfiedIn (PairVar (A := A)) (RAtom (A := A)) F ι
    112
    113open Lax904597.Problems Lax799700.Problems
    114
    115/-- BCQ containment: is the left query contained in the right one? -/
    116def CQContainment : DecisionProblem queryPair :=
    117 DecisionProblem.ofPred QueryContained
    118
    119end Lax420092.QueryPairs
    120

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above.

    Loading discussion…