Boolean conjunctive query evaluation

Lax420092.Evaluation · concepts/Lax420092/Evaluation.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

    A conjunctive query with given variables and atoms over the elements of an instance is satisfied in a database, a binary relation on some universe with a denotation of the instance's elements, when some valuation of the elements into the universe agrees with the denotation on the non-variables and sends every atom to an edge of the database. The homomorphism form takes the instance's own universe as database, every non-variable denoting itself. The query of an evaluation instance holds in its database when the homomorphism condition is met with the database edges as facts, the classical semantics of Boolean conjunctive queries under set semantics. CQEval is the decision problem of the structures isomorphic to an instance whose query holds.

    Concept map
    8 concepts; 10 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 Lax420092.QueryDatabases
    17import Lax904597.Classes
    18import Lax799700.Problems
    19
    20/-!
    21---
    22title: Boolean conjunctive query evaluation
    23type: definition
    24---
    25A conjunctive query with given variables and atoms over the elements of an
    26instance is satisfied in a database, a binary relation on some universe
    27with a denotation of the instance's elements, when some valuation of the
    28elements into the universe agrees with the denotation on the non-variables
    29and sends every atom to an edge of the database. The homomorphism form
    30takes the instance's own universe as database, every non-variable denoting
    31itself. The query of an evaluation instance holds in its database when the
    32homomorphism condition is met with the database edges as facts, the
    33classical semantics of Boolean conjunctive queries under set semantics.
    34CQEval is the decision problem of the structures isomorphic to an instance
    35whose query holds.
    36-/
    37
    38namespace Lax420092.Evaluation
    39
    40open Lax420092.QueryDatabases
    41
    42open FirstOrder
    43
    44open Language Structure BoundedFormula
    45
    46section GenericCore
    47
    48variable {A B : Type}
    49
    50/-- The conjunctive query with variables `VarP` and atoms `AtomP` (over
    51instance elements `A`) is satisfied in the database `F` on universe `U`,
    52where `ι` fixes the denotation of the non-variables: some valuation extends
    53`ι` and maps every atom to a database edge. -/
    54def SatisfiedIn (VarP : A → Prop) (AtomP : A → A → Prop) {U : Type}
    55 (F : U → U → Prop) (ι : A → U) : Prop :=
    56 ∃ v : A → U, (∀ x, ¬VarP x → v x = ι x) ∧ ∀ x y, AtomP x y → F (v x) (v y)
    57
    58/-- The homomorphism condition: satisfaction in a database carried by the
    59instance's own universe, with every non-variable denoting itself. This single
    60notion underlies both problems below. -/
    61def CQHom (VarP : A → Prop) (AtomP FactP : A → A → Prop) : Prop :=
    62 SatisfiedIn VarP AtomP FactP id
    63
    64end GenericCore
    65
    66/-- The query of an evaluation instance holds in its database: there is a
    67valuation of the elements, fixing the non-variables, that maps every query
    68atom to a genuine database edge. This is the classical semantics of Boolean
    69conjunctive queries, phrased as a homomorphism into the database half of the
    70instance. -/
    71def QueryHolds (A : Type) [queryDb.Structure A] : Prop :=
    72 CQHom (QVar (A := A)) (QAtom (A := A)) (DbEdge (A := A))
    73
    74open Lax904597.Problems Lax799700.Problems
    75
    76/-- BCQ evaluation: does the query of the instance hold in its database? -/
    77def CQEval : DecisionProblem queryDb :=
    78 DecisionProblem.ofPred QueryHolds
    79
    80end Lax420092.Evaluation
    81

    Discussion

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

    Loading discussion…