While this submission is a draft, it cannot be used by other submissions.

The Personnel example, rewritten

Lax392996.RewritingExample · concepts/Lax392996/RewritingExample.lean · lax-392996

proven

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

    Example

    The paper's Example 11: the rewriting rules applied bottom up to qcityq_{\mathrm{city}}, for any annotation type K\mathbb{K}, give γ1[#2:⊕](Π#4,#9(σ#4=#8∧#1<#5(Π#1,…,#4,#6,…,#9,#5⊗#10(P×P))))\gamma_1[\#2 : \oplus](\Pi_{\#4, \#9}(\sigma_{\#4 = \#8 \wedge \#1 < \#5} (\Pi_{\#1, \dots, \#4, \#6, \dots, \#9, \#5 \otimes \#10}(P \times P)))), the cross product rewritten by (R2), the projection by (R1) and the duplicate elimination by (R3), the selection carried over to the composite tuples. The claim is that equation, on the queries as syntax; the equality of its two semantics is an instance of the correctness theorem. Attributes are numbered from 0 here, from 1 in the paper.

    Concept map
    6 concepts
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A
    Evidence

    Each proof establishes this claim relative to its assumptions.

    In the paper

    • page 5 of this submission's paper

    Lean source view on GitHub

    1import Mathlib.Data.Fin.VecNotation
    2import Lax392996.Databases
    3import Lax392996.RelationalAlgebra
    4import Lax392996.RewritingRules
    5import Lax392996.PersonnelExample
    6
    7/-!
    8---
    9title: The Personnel example, rewritten
    10type: example
    11---
    12The paper's Example 11: the rewriting rules applied bottom up to
    13qcityq_{\mathrm{city}}, for any annotation type K\mathbb{K}, give
    14γ1[#2:⊕](Π#4,#9(σ#4=#8∧#1<#5(Π#1,…,#4,#6,…,#9,#5⊗#10(P×P))))\gamma_1[\#2 : \oplus](\Pi_{\#4, \#9}(\sigma_{\#4 = \#8 \wedge \#1 < \#5} (\Pi_{\#1, \dots, \#4, \#6, \dots, \#9, \#5 \otimes \#10}(P \times P))))
    15,
    16the cross product rewritten by (R2), the projection by (R1) and the
    17duplicate elimination by (R3), the selection carried over to the composite
    18tuples. The claim is that equation, on the queries as syntax; the equality
    19of its two semantics is an instance of the correctness theorem. Attributes
    20are numbered from 0 here, from 1 in the paper.
    21-/
    22
    23namespace Lax392996.RewritingExample
    24
    25open Lax392996.Databases Lax392996.RelationalAlgebra Lax392996.RewritingRules
    26open Lax392996.PersonnelExample
    27
    28/-- The rewritten query, as the paper traces it. -/
    29def qcityRewritten (K : Type) : Query (String ⊕ K) 2 :=
    30 Query.ProvSum (fun k : Fin 1 => k.castLE (by omega)) (Term.index 1)
    31 (Query.Proj ![Term.index 3, Term.index 8]
    32 (Query.Sel (Selection.And (Selection.BT (BoolTerm.EQ (Term.index 3) (Term.index 7)))
    33 (Selection.BT (BoolTerm.LT (Term.index 0) (Term.index 4))))
    34 (Query.Proj ![Term.index 0, Term.index 1, Term.index 2, Term.index 3,
    35 Term.index 5, Term.index 6, Term.index 7, Term.index 8,
    36 Term.mul (Term.index 4) (Term.index 9)]
    37 (@Query.Prod _ 5 5 10 rfl (Query.Rel 5 "Personnel") (Query.Rel 5 "Personnel")))))
    38
    39/-- Example 11: the rewriting of `q_city` is the traced query. -/
    40axiom qcity_rewriting : ∀ (K : Type) (hq : qcity.source),
    41 Query.rewriting (K := K) qcity hq = qcityRewritten K
    42
    43end Lax392996.RewritingExample
    44
    Show Proof

    Discussion

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

    Loading discussion…