+ All Categories
Home > Documents > CS319-course-ArmstrongCompleteSound

CS319-course-ArmstrongCompleteSound

Date post: 09-Apr-2018
Category:
Upload: tamfin
View: 220 times
Download: 0 times
Share this document with a friend

of 33

Transcript
  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    1/33

    Dr. Alexandra I. Cristeahttp://www.dcs.warwick.ac.uk/~acristea/

    CS 319: Theory of Databases: C3

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    2/33

    (provisionary) Content

    1. Generalities DB2. Integrity constraints (FD revisited)

    3. Relational Algebra (revisited)

    4. Query optimisation

    5. Tuple calculus6. Domain calculus

    7. Query equivalence

    8. LLJ, DP and applications

    9. Temporal Data10. The Askew Wall

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    3/33

    previous

    Proving with Armstrong axioms

    (non)Redundancy of FDs

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    4/33

    FD Part 3

    Soundness and Completeness ofArmstrongs axioms

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    5/33

    Armstrongs Axioms:

    Sound & CompleteIngredients: Functional Dependency (reminder)

    Definition

    Inference rules

    Closure of F : F*F+: Set of all FDs obtained by applying inferences rules on a basic set

    of FDs

    Issues and resolutions

    Armstrongs Axioms (reminder) 3 inferences rules for obtaining the closure of F

    Properties of the Armstrongs AxiomsThey are a sound an complete set of inference rules

    Proof of the completeness

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    6/33

    Functional Dependency

    - A functional dependency (FD) has the formXYwhereXand Yare sets of attributes in a relation R

    XY iff any two tuples that agree onXvalue also agree on Yvalue

    XYif and only if:

    for any instance rof R

    for any tuples t1 and t2 ofr

    t1(X) = t2(X) t1(Y) = t2(Y)

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    7/33

    Inference of Functional

    Dependencies Suppose R is a relation scheme, and F is a set of functionaldependencies for R

    If X, Y are subsets of attributes of Attr(R) and if all instances r ofR which satisfy the FDs in F also satisfy X Y, then we say thatF entails (logically implies) X Y, written F | X Y

    In other words:

    there is no instance r of R that does not satisfy X Y

    Example

    if F = { A B, B C } then F | A Cif F = { S A, SI P } then

    F | S I AP, F | SP SAP etc.

    A B C

    S A

    PI

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    8/33

    Functional Dependency

    Issue: How to represent set ofALL FDs for a relation R?

    Solution Find a basic set of FDs ((canonical) cover)

    Use axioms for inferring

    Represent the set of all FDs as the set of FDs that can be inferredfrom a basic set of FDs

    Axioms they must be a sound and complete set of inference rules

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    9/33

    Set of Functional Dependencies F*

    Formal Definition of F*, the covercoverof F:

    Informal Definitions F* is the set of all FDs logically implied by F

    (entailed)

    ... usually F* is much too large even to enumerate!

    if F is a set of FDs, then F* { X Y FX Y }

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    10/33

    F* Usually F* is much too large even to

    enumerate! Example (3 attributes, 2 FDs and 43 entailed

    dependencies)

    Attr(R)=ABC and F ={ A B, B C } then F* isA S for all [subset of ABC] 8 FDsB BC, B B, B C, B 4 FDsC C, C , 3 FDs

    AB S for all subsets S of ABC 8 FDsAC S for all subsets S of ABC 8 FDsBC BC, BC B, BC C, BC 4 FDsABC S for all subsets S of ABC 8 FDs

    A B C

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    11/33

    Armstrongs Axioms

    Axioms for reasoning about FDs

    F1: reflexivity if Y X then X Y

    F2: augmentation if X Y then XZ YZ

    F3: transitivity if X Y and Y Z then X Z

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    12/33

    F+

    Informal Definition

    Formal Definition

    F+(the closureclosure of F)is the set of dependencies which canbe deduced from Fby applying Armstrongs axioms

    if F is a set of FDs, then F+ { X Y F |= X Y }

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    13/33

    Armstrongs Axioms

    Theorem:Armstrongs axioms are a sound and complete

    set of inference rules

    Sound: all Armstrong axioms are valid (correct / hold) Complete: all fds that are entailed can be deduced with

    the help of the Armstrong axioms

    How to: Prove the soundness?

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    14/33

    Armstrongs Axioms

    Theorem: Armstrongs axioms are a sound andcomplete set of inference rules Sound: the Armstrongs rules generate only FDs in F*

    F+ F* Complete: the Armstrongs rules generate all FDs in F*

    F* F +

    If complete and sound then F+ = F*

    Here

    Proof of the completeness

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    15/33

    Armstrongs Theorems

    Additional rules derived from axioms Union

    ifA B and AC, then ABC

    Decomposition

    ifABC, then A B and A C

    A B

    C

    AB

    C

    For the proof, we can use:

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    16/33

    Completeness of the

    Armstrongs Axioms

    Proving that Armstrongs axioms are acomplete set of inference rules

    Armstrongs axioms generate all FDs inF*

    F*

    F +

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    17/33

    Completeness of the

    Armstrongs Axioms First define X+, the closure of X with respect to F:

    X+ is the set of attributes A such that X A can be deduced

    from F with Armstrongs axioms

    Note that we can deduce thatX Y for some set Y byapplying Armstrongs axioms if and only if Y X+

    Attr(R)=LMNO

    X=L

    F={L M , M N, O N}then X+ = L+ = LMN

    L M N

    O

    Example:

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    18/33

    X

    Y F+

    Y

    X

    +

    Proof: We can deduce thatX Y for some set Y by applyingArmstrongs axioms if and only if Y X+

    Y X+XY F+ Y X+and suppose that A Y then X A F+ (definition of X+) A Y: X A F+ X Y F+(union rule)

    XY F+ Y X+ X Y F

    +

    and suppose that A Y then X A F+

    (decomposition rule) A X+ (definition of X+) A Y: A X+ Y X+

    C l t ( * ) f th

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    19/33

    Completeness (F* F +) of theArmstrongs Axioms

    Completeness:

    (R, X,Y Attr(R), F true in R : : X Y F* => X Y F +)

    Idea: (A => B) (A v B) (B v A) (B =>A)

    To establish completeness, it is sufficient to show:

    if X Y cannot be deduced from F using Armstrongs axioms then also X Y is notlogically implied by F:

    (R, X,Y Attr(R), F true in R : : X Y F+=> X Y F*)

    (In other words) there is a relational instance rin R (rR) in which all thedependencies in F are true, but X Y does not hold

    XXYY F*F* enough:enough:

    Counter example!!Counter example!!

    C l t f th

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    20/33

    Completeness of the

    Armstrongs Axioms

    Example for the proof idea for a given R, F, X:If X Y cannot be deduced using Armstrongs axioms: then thereis a relational instance for R in which all the dependencies in F are

    true, but X Y does not hold

    Counter example:

    R=LMNO

    X=L

    F={L M , M N, O N}then X+ = LMN

    L M N

    O

    L O cannot bededuced (so not in F+)

    but also does not hold

    (not in F*)

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    21/33

    What we want to prove thus:

    (R, X,Y Attr(R), F true in R : : X Y F+ => X Y F*)

    (In other words) Counterexample by construction:

    for any R, any X, Y, any F true in R, with X->Y not inferable from the axioms

    there is a relational instance rin R (rR) in which all the dependencies in F are true (F true in R ), but X Y does not hold

    Completeness of the

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    22/33

    Completeness of the

    Armstrongs Axioms

    Suppose one can not deduce X Y from Armstrongsaxioms for an arbitrary R, F, X,Y; construct counter-ex. Consider the instance r

    0for R with 2 tuples

    (assuming Boolean attributes, or more generally, that the twotuples agree on X+ but disagree elsewhere)

    Attributes of X+ Other Attributes

    1 1 1 1 1 1

    1 1 . 1 0 0 0

    Relational instance r0 for R with 2 tuplesL+ = LMNL M N O

    1 1 1 1

    1 1 1 0

    R=LMNO

    X=L

    then X+ = L+

    L O cannot

    be deduced

    Example:

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    23/33

    Completeness of the

    Armstrongs Axioms Check that all the dependencies in F are true in R:

    Suppose that V W is a dependency in F If V is not a subset of X+, the dependency holds in r

    0

    If V is a subset of X+

    , then both X V, and then X W can bededuced by Armstrongs axioms. This means that W is a

    subset of X+, and thus V W holds in r0

    Attributes of X+

    Other Attributes1 1 1 1 1 1

    1 1 . 1 0 0 0

    Relational instance r0 for R with 2 tuples

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    24/33

    Completeness of the

    Armstrongs Axioms

    Check that all the dependencies in F are true

    Extended Example (more tuples)

    O N is a dependency in F but O is not a subset of X+,

    the dependency holds in r0

    M N is a dependency in F and M is a subset of X+, thenboth L M, and L N can be deduced by Armstrongs

    axioms. This means that N is a subset of X+, and thus M N holds in r0

    R=LMNO

    X=L

    F={L M , M N, O N}then X+ = LMN

    Completeness of the

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    25/33

    Completeness of the

    Armstrongs Axioms

    Proof that X Y does not hold in r0:

    Recall that we can deduce thatX Y for some set Y by

    applying Armstrongs axioms if and only if Y X+

    By assumption, we cant deduce that X Y holds in r0

    Hence Y contains (at least) an attribute not in the subset X+,

    confirming that X Y does not hold in r0

    Attributes of X+ Other Attributes

    1 1 1 1 1 1

    1 1 . 1 0 0 0

    Relational instance r0 for R with 2 tuples

    (R, X,Y Attr(R), F true in R : : X -> Y F+ => X -> Y F*)

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    26/33

    Completeness of the

    Armstrongs Axioms

    We have proved the correctness (last module) andhere, the completeness of ArmstrongsAxioms: How can we prove the completeness of another set

    of rules?

    Repeat the proof for this set Deduce the Armstrongs Axioms from this set

    How can we disprove the completeness of anotherset of rules?

    By showing (via a counterexample) that someconsequence of Armstrong's rules cannot be deducedfrom them (see the proof technique for non-redundancy)

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    27/33

    Completeness of the

    Armstrongs Axioms

    Exercise Are the following set of rules a sound and complete set of

    inference rules? (X, Y, Z, W R)S1: X XS2: if X Y then XZ YS3: if X Y, Y Z then XW ZW

    (This is a typical exam question )

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    28/33

    Solution (soundness)

    XX so by F1

    YXif then by F2

    XX

    YZXZ

    so by F1 YYZYZY

    so by F3 YXZYYZYZXZ ,YXZ

    YX

    ZYYX ,if then by F3 ZX

    so by F2 ZWXW ZWXW

    ZYYX

    ,

    S1

    S2

    S3

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    29/33

    Solution (completeness)

    XY so {S1} YY,{S2}YZY

    if XYZZ = ::then henceXY

    YX {S1}XX, XY, so

    {S3}XZYZ

    if then hence

    YZXZ

    YX

    A1

    A2

    A3ZYYX ,if

    then {S3}hence

    ZX

    ZYYX

    ,00 // ZX

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    30/33

    Completeness of the

    Armstrongs Axioms

    Exercises Are the following set of rules a complete set of inference rules?

    1111

    111

    11

    11

    A B AB

    A

    B

    AB

    }0{},,{)( AFBARAtt /==

    Suppose

    Apply above rules exhaustively

    ABB

    Hence: answer is NO

    obtained from F1-3

    but not from R1-3

    R1: X X

    R2: X Y then XZ YR3: X Y, Y Z then X Z

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    31/33

    Summary

    We have learned how to prove that theArmstrong axiom set is complete (and

    we already knew it is sound)

    We can now prove the soundness andcompleteness of any other set of

    axioms

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    32/33

    Extra Question: Can we have a sound and complete set of

    inference rules consisting of only 2 rules? What about 1 rule?

  • 8/7/2019 CS319-course-ArmstrongCompleteSound

    33/33

    o follow

    pendency preserving, Lossless join,rmal forms algorithms


Recommended