logic aspects of databases
play

Logic Aspects of Databases teacher: doc. RNDr. Stanislav Kraj ci, - PowerPoint PPT Presentation

Pavol Jozef Saf arik University in Ko sice Faculty of Science Supportive textbooks in course Logic Aspects of Databases teacher: doc. RNDr. Stanislav Kraj ci, PhD. study programme: Informatics Project 2005/NP1-051 11230100466


  1. Pavol Jozef ˇ Saf´ arik University in Koˇ sice Faculty of Science Supportive textbooks in course Logic Aspects of Databases teacher: doc. RNDr. Stanislav Krajˇ ci, PhD. study programme: Informatics Project 2005/NP1-051 11230100466 Stanislav Krajˇ ci Logic Aspects of Databases

  2. Administrative information ◮ assessment: examination ◮ duration: 2 hours per week, 26 hours per study ◮ final examination: written test ◮ course objective: to acquire information connecting logic and the databases theory ◮ course content: first order logic, database, relational algebra Stanislav Krajˇ ci Logic Aspects of Databases

  3. Recommended reading ◮ S. Abiteboul, R. Hull, V. Vian: Foundations of Databases, Addison-Wesley Publishing Company, 1995, ISBN 0-201-53771-0 Stanislav Krajˇ ci Logic Aspects of Databases

  4. 1 LOGIC PRELIMINARIES Stanislav Krajˇ ci Logic Aspects of Databases

  5. Basic logic symbols ◮ UCnn = {¬ ¬ ¬} – unary connectives ◮ BCnn = {∧ ∧ ∧ , ∨ ∨ ∨ , → → → , ↔ ↔ ↔ , ↑ ↑ ↑ , ↓ ↓ ↓ , ⊕ ⊕} – binary connectives ⊕ ◮ Cnn = UCnn ∪ BCnn – connectives ◮ Qua = {∀ ∀ ∃ ∀ , ∃ ∃} – quantifiers ◮ Aux = { ( ( ( , ) ) ) ,, , , } – auxiliary symbols ◮ BLS = Cnn ∪ Qua ∪ Aux – basic logic symbols Stanislav Krajˇ ci Logic Aspects of Databases

  6. Typed first order logic 1/2 ◮ sets of special symbols ◮ Dat L – data types ◮ Var L – variables ◮ Con L – constant symbols ◮ Fun L – function symbols ◮ Pre L – predicate symbols ◮ all these sets are disjoint and disjoint of BLS Stanislav Krajˇ ci Logic Aspects of Databases

  7. Typed first order logic 2/2 ◮ L = � Dat L , typVar L , typCon L , sigFun L , sigPre L � – typed first order logic ◮ typVar L : Var L → Dat L – variable types ◮ typCon L : Con L → Dat L – constant symbol types ◮ sigFun L : Fun L → � n ∈ N + Dat n L × Dat L – function symbol signatures ◮ sigPre L : Pre L → � n ∈ N + Dat n L – predicate symbol signatures ◮ all often written without the index L Stanislav Krajˇ ci Logic Aspects of Databases

  8. Terms ◮ Trm L (or shortly Trm ) – the least set fulfilling the following conditions: 1a Var L ⊆ Trm L and typ ( v ) = typVar ( v ) for each v ∈ Var L , 1b Con L ⊆ Trm L and typ ( c ) = typCon ( c ) for each c ∈ Con L 2 if f ∈ Fun L s.t. sigFun ( f ) = �� D 1 , . . . , D n � , D � and for all i ∈ { 1 , . . . , n } , t i ∈ Trm L s.t. typ ( t i ) = D i then t = f ( ( t 1 , ( , , . . ., , , t n ) ) ) ∈ Trm L and typ ( t ) = D ◮ L-terms (or shortly terms ) – elements of Trm L Stanislav Krajˇ ci Logic Aspects of Databases

  9. Formulae ◮ Frm L (or shortly Frm ) – the least set fulfilling the following conditions: 1 if p ∈ Pre L s.t. sigPre ( p ) = � D 1 , . . . , D n � and for all i ∈ { 1 , . . . , n } , t i ∈ Trm L s.t. typ ( t i ) = D i ( , , ) ) ∈ Frm L then p ( ( t 1 , , . . ., , t n ) (so-called atomic formulae or atoms ) 2a if ψ ∈ Frm L then ( ( ( ¬ ¬ ¬ ψ ) ) ) ∈ Frm L 2b if ψ 1 , ψ 2 ∈ Frm L and @ ∈ BCnn then ( ( ( ψ 1 @ ψ 2 ) ) ) ∈ Frm L 2c if ψ ∈ Frm L , # ∈ Qua and v ∈ Var L then ( (( ( ( (# v ) ) ) ψ ) ) ) ∈ Frm L ◮ L-formulae (or shortly formulae ) – elements of Frm L Stanislav Krajˇ ci Logic Aspects of Databases

  10. Constant symbols in terms ◮ define function ConTrm : Trm → P ( Con ) in the following way: 1a if t = v ∈ Var then ConTrm ( t ) = ∅ 1b if t = c ∈ Fun then ConTrm ( t ) = { c } 2 if t = f ( ( ( t 1 , , , . . ., , , t n ) ) ) then ConTrm ( t ) = � i ∈{ 1 ,..., n } ConTrm ( t i ) Stanislav Krajˇ ci Logic Aspects of Databases

  11. Variables in terms ◮ define function VarTrm : Trm → P ( Var ) in the following way: 1a if t = v ∈ Var then VarTrm ( t ) = { v } 1b if t = c ∈ Fun then VarTrm ( t ) = ∅ 2 if t = f ( ( ( t 1 , , , . . ., , , t n ) ) ) then VarTrm ( t ) = � i ∈{ 1 ,..., n } VarTrm ( t i ) Stanislav Krajˇ ci Logic Aspects of Databases

  12. Free and bounded variables in formulae ◮ define functions FVarFrm , BVarFrm : Frm → P ( Var ) in the following way: ( , , ) 1 if ϕ = p ( ( t 1 , , . . ., , t n ) ) then FVarFrm ( ϕ ) = � i ∈{ 1 ,..., n } VarTrm ( t i ) and BVarFrm ( ϕ ) = ∅ ( ( ¬ ¬ ¬ ψ ) ) 2a if ϕ = ( ) then FVarFrm ( ϕ ) = FVarFrm ( ψ ) and BVarFrm ( ϕ ) = BVarFrm ( ψ ) ( ) 2b if ϕ = ( ( ψ 1 @ ψ 2 ) ) then FVarFrm ( ϕ ) = FVarFrm ( ψ 1 ) ∪ FVarFrm ( ϕ 2 ) and BVarFrm ( ϕ ) = BVarFrm ( ψ 1 ) ∪ BVarFrm ( ϕ 2 ) 2c if ϕ = ( ( (( (# v ) ( ) ) ψ ) ) ) then FVarFrm ( ϕ ) = FVarFrm ( ψ ) � { v } and BVarFrm ( ϕ ) = BVarFrm ( ψ ) ∪ { v } ◮ define VarFrm ( ϕ ) = FVarFrm ( ϕ ) ∪ BVarFrm ( ϕ ) Stanislav Krajˇ ci Logic Aspects of Databases

  13. Pre-interpretation ◮ data type interpretation : if D ∈ Dat then IntDat ( D ) is some non-empty set ◮ constant symbol interpretation : if c ∈ Con and typCon ( c ) = D then IntCon ( c ) ∈ IntDat ( D ) ◮ function symbol interpretation : if f ∈ Fun and sigFun ( f ) = �� D 1 , . . . , D n � , D � then IntFun ( f ) : IntDat ( D 1 ) × · · · × IntDat ( D n ) → IntDat ( D ) ◮ such � IntDat , IntCon , IntFun � is called a pre-interpretation Stanislav Krajˇ ci Logic Aspects of Databases

  14. Evaluation of variables ◮ evaluation of variables : an arbitrary function E s. t. Dom ( E ) = Var and E ( v ) ∈ typVar ( v ) ◮ if E is an evaluation of variables, v is a variable and m ∈ IntDat ( typVar ( v )) then define E v / m in the following way: � if w � = v E ( w ) E v / m ( w ) = m if w = v Stanislav Krajˇ ci Logic Aspects of Databases

  15. Evaluation of terms ◮ let E is an evaluation of variables and � IntDat , IntCon , IntFun � is a pre-interpretation ◮ define function E with Dom ( E ) = Trm by induction: 1a if t = v ∈ Var then E ( t ) = E ( v ) 1b if t = c ∈ Con then E ( t ) = IntCon ( c ) 2 if t = f ( ( t 1 , ( , , . . ., , , t n ) ) ) where f ∈ Fun and t 1 , . . . , t n ∈ Trm then E ( t ) = ( IntFun ( f )) ( E ( t 1 ) , . . . , E ( t n )) Stanislav Krajˇ ci Logic Aspects of Databases

  16. Interpretation of predicate symbols ◮ let p ∈ Pre and sigPre ( p ) = � D 1 , . . . , D n � ◮ two possible interpretations: ◮ as a relation: IntPreRel ( p ) ⊆ IntDat ( D 1 ) × · · · × IntDat ( D n ) ◮ (alternatively) as a function to a set TrV of truth values : IntPreFun ( p ) : IntDat ( D 1 ) × · · · × IntDat ( D n ) → TrV ◮ if TrV = { 0 , 1 } both interpretations are clearly in this correspondence: � x 1 , . . . , x n � ∈ IntPreRel ( p ) iff ( IntPreFun ( p )) ( x 1 , . . . , x n ) = 1 Stanislav Krajˇ ci Logic Aspects of Databases

  17. Basic Boolean functions 1/2 ◮ x y ∨ ( x , y ) ∧ ( x , y ) → ( x , y ) ↔ ( x , y ) B ∨ B ∧ B → B ↔ ∨ ∧ → ↔ 0 0 0 0 1 1 0 1 1 0 1 0 1 0 1 0 0 0 1 1 1 0 1 1 ◮ x y B ↓ ↓ ( x , y ) B ↑ ↑ ( x , y ) B ⊕ ⊕ ( x , y ) ⊕ ↓ ↑ 0 0 1 1 0 0 1 0 1 1 1 0 0 1 1 1 1 0 0 0 Stanislav Krajˇ ci Logic Aspects of Databases

  18. Basic Boolean functions 2/2 ◮ x B ¬ ¬ ( x ) ¬ 0 1 1 0 ◮ X B ∃ ∃ ( X ) B ∀ ∀ ( X ) ∃ ∀ ∅ 0 1 { 0 } 0 0 { 1 } 1 1 { 0 , 1 } 1 1 Stanislav Krajˇ ci Logic Aspects of Databases

  19. Evaluation of formulae ◮ let E is an evaluation of variables, � IntDat , IntCon , IntFun � is a pre-interpretation and IntPreFun is a interpretation of predicate symbols ◮ define function E with Dom ( E ) = Frm by induction: 1 if ϕ = p ( ( ( t 1 , , , . . ., , t n ) , ) ) where f ∈ Fun and t 1 , . . . , t n ∈ Trm then E ( ϕ ) = ( IntPreFun ( p )) ( E ( t 1 ) , . . . , E ( t n )) ¬ 2a if ϕ = ( ( ( ¬ ¬ ψ ) ) ) where ψ ∈ Frm then E ( ϕ ) = B ¬ ¬ ( E ( ψ )) ¬ 2b if ϕ = ( ( ( ψ 1 @ ψ 2 ) ) ) where ψ 1 , ψ 2 ∈ Frm and @ ∈ BCnn then E ( ϕ ) = B @ ( E ( ψ 1 ) , E ( ψ 2 )) ( ( ) ) ) where ψ ∈ Frm , # ∈ Qua and v ∈ Var 2c if ϕ = ( (( (# v ) ) ψ ) then E ( ϕ ) = B # ( { E v / m ( ψ ) : m ∈ IntDat ( typVar ( v )) } ) Stanislav Krajˇ ci Logic Aspects of Databases

  20. Substitution ◮ σ : Var → Trm is called a substitution if for all v ∈ Var , typ ( σ ( v )) = typVar ( v ) ◮ a special case – identity Id : for all v ∈ Var , Id ( v ) = v ◮ if σ is a substitution, w is a variable and t is a term s. t. typ ( t ) = typVar ( w ) then σ w / t is a substitution defined by � t , if v = w σ w / t ( v ) = if v � = w σ ( v ), Stanislav Krajˇ ci Logic Aspects of Databases

  21. Substitution to a term ◮ let σ is a substitution ◮ define σ : Trm → Trm : 1a if t = v ∈ Var then σ ( t ) = σ ( v ) 1b if t = c ∈ Con then σ ( t ) = c 2 if t = f ( ( ( t 1 , , , . . ., , , t n ) ) ) where f ∈ Fun and t 1 , . . . , t n ∈ Trm then σ ( t ) = f ( ( ( σ ( t 1 ) , , , . . ., , ,σ ( t n )) ) ) Stanislav Krajˇ ci Logic Aspects of Databases

Recommend


More recommend