SlideShare uma empresa Scribd logo
1 de 13
Baixar para ler offline
gebruik van quantoren in
relationele calculus

dr. Katrien Verbert
Katrien.Verbert@cs.kuleuven.be
tupel relationele calculus
•  Basisvorm: {t | formule(t)}
   –  t is een tupelvariabele en formule(t) een formule waarin
      tupelvariable t voorkomt.


•  Resultaat:
   –  Verzameling van alle tupels t waarvoor formule(t) waar is.


•  Formule bestaat uit:
   –  atomen + logische connectoren + quantificatoren




                                                                   2
voorbeeld

•  { t | EMPLOYEE(t) and t.SALARY > 50000 }




                                              3
formule

•  wordt uitgedrukt in predicatenlogica
•  maakt gebruik van
   –  variabelen
   –  constanten
   –  vergelijkingsoperatoren
                 =≠<>≥≤
   –  logische connectoren
                 ¬∧∨⇔⇒
   –  quantificatie van variabelen: ∃ (er bestaat), ∀ (voor alle)




                                                                    4
voorbeeld                  connector          constante


•  { t | EMPLOYEE(t) and t.SALARY > 50000 }



                                   vergelijkingsoperator

      variabele




                                                      5
quantoren

•  Existentiële quantor: ∃       (er bestaat)
•  Universele quantor: ∀         (voor alle)

•  (∃t)(formule(t))
   –  er bestaat een tupel t die aan de conditie voldoet
   –  bv. (∃t)(EMPLOYEE(t) and t.fname=‘John’)



•  (∀t)(formule(t))
   –  alle tuples in het universum voldoen aan de conditie



                                                             6
•  Q_1
   –  Geef naam en adres van alle werknemers die voor het
      'Research' departement werken


    { t.Fname, t.Lname, t.Address | EMPLOYEE(t)  
                                    AND (∃d) (DEPARTMENT(d)  
                                          AND d.Dname = 'Research’ 
                                          AND d.Number = t.Dno) } 


existentiële quantor: moet waar zijn voor tenminste één tuple

we vragen werknemers op waarvoor er een gerelateerd tupel in
de departement tabel bestaat met als naam ‘Research’
gebruik van universele quantoren

•  (∀x) (P(x))
   –  waar als P(x) waar is voor elke x van het universum
   –  bv. (∀x) (x.color = “Rood”)
   –  betekent dat alles wat bestaat rood is


•  logische implicatie
   –  (∀x) (Boot(x) ⇒ (x.color = “Rood”))
   –  (∀x) IF Boot(x) THEN (x.color = “Rood”)

   –  Als x een boot is, dan moet de kleur rood zijn




                                                            8
gebruik van universele quantoren

•  ⇒ is een logische implicatie
   –  a ⇒ b betekent dat als a waar is, ook b waar moet zijn
   –  a ⇒ b is hetzelfde als ¬a ∨ b


•  (∀x) (x.dnum=5 ⇒ F2)
•  (∀x) IF x.dnum=5 THEN F2
•  (∀x) (not (x.dnum=5) or F2)
   –  x.dnum=5: F2 moet waar zijn




                                                               9
gebruik van universele quantoren


•  (∀x) (Boot(x) ⇒ (x.color = ‘Rood’))

•  ⇒ is een logische implicatie
   –  als x een boot is, dan moet de kleur rood zijn


•  (∀x) (¬Boot(x) ∨ x.color = ‘Rood’)
   –  X is geen boot: conditie is waar
   –  X is een boot: x.color=‘Rood’ moet waar zijn




                                                       10
–  Q_3: Geef de namen van de werknemers die aan alle projecten
   werken


              { e.Lname, e.Fname |  
               EMPLOYEE(e)  
               AND  
               ( (∀x) ( NOT (PROJECT(x))  
                         OR  
                         ( (∃w) ( WORKS_ON(w) 
                                   AND w.Essn = e.Ssn 
                                   AND x.Pnumber = w.Pno ) ) ) ) } 


       In woorden: als x een project is, dan moet er een 
       overeenkomsUg tupel in de works_on tabel bestaan. 

                                                                      11
{ e.Lname, e.Fname |  
              EMPLOYEE(e)  
              AND  
              ( (∀x) ( NOT (PROJECT(x))  
                        OR  
                        ( (∃w) ( WORKS_ON(w) 
                                  AND w.Essn = e.Ssn 
                                  AND x.Pnumber = w.Pno ) ) ) ) } 


–  ( ∀ x ) ( F ) :
    •  moet voldaan zijn voor alle tuples in het universum die aan x kunnen
       worden toegekend
–  daarom:
    •  ( ∀ x ) ( not PROJECT ( x ) )
    •  alle tupels die niet tot PROJECT behoren uitsluiten van verdere
       selectievoorwaarde
–  verder moet dus gelden voor een employee e dat hij werkt op
   elk project dat niet uitgesloten werd


                                                                              12
•  Q_6
  –  Geef de namen van alle werknemers zonder personen ten
     laste:



     {e.Fname, e.Lname  |  
       EMPLOYEE(e) AND 
      ( (∀ d) ( NOT (DEPENDENT(d)) OR NOT (e.Ssn = d.Essn) ) ) }




                                                                    13

Mais conteúdo relacionado

Mais procurados

Integraalrekening 1 les 2
Integraalrekening 1 les 2Integraalrekening 1 les 2
Integraalrekening 1 les 2Bart Habraken
 
Integraalrekening 1 les 3
Integraalrekening 1 les 3Integraalrekening 1 les 3
Integraalrekening 1 les 3Bart Habraken
 
Integraalrekening 1 les 5
Integraalrekening 1 les 5Integraalrekening 1 les 5
Integraalrekening 1 les 5Bart Habraken
 
Integraalrekening 1 les 6
Integraalrekening 1 les 6Integraalrekening 1 les 6
Integraalrekening 1 les 6Bart Habraken
 
Lyceo Wiskunde B Hoofdstuk 2 1 Differentieren
Lyceo Wiskunde B Hoofdstuk 2 1 DifferentierenLyceo Wiskunde B Hoofdstuk 2 1 Differentieren
Lyceo Wiskunde B Hoofdstuk 2 1 DifferentierenLyceo Examentraining
 
Integraalrekening 1 les 7
Integraalrekening 1 les 7Integraalrekening 1 les 7
Integraalrekening 1 les 7Bart Habraken
 
Lyceo Wiskunde B Hoofdstuk 1 1 Standaardfuncties
Lyceo Wiskunde B Hoofdstuk 1 1 StandaardfunctiesLyceo Wiskunde B Hoofdstuk 1 1 Standaardfuncties
Lyceo Wiskunde B Hoofdstuk 1 1 StandaardfunctiesLyceo Examentraining
 
Inleiding calculus 1415 les 7 gv alst
Inleiding calculus 1415 les 7 gv alstInleiding calculus 1415 les 7 gv alst
Inleiding calculus 1415 les 7 gv alstGerard van Alst
 
1112 31103 05 functies in ms excel 2010-deel1
1112 31103 05  functies in ms excel 2010-deel11112 31103 05  functies in ms excel 2010-deel1
1112 31103 05 functies in ms excel 2010-deel1thomvansas
 
VWO wiskunde B 2012
VWO wiskunde B 2012VWO wiskunde B 2012
VWO wiskunde B 2012IvET
 
20130214 les gb2
20130214 les gb220130214 les gb2
20130214 les gb2Erik Duval
 
Lyceo Wiskunde B Hoofdstuk 2 2 Integraalrekening
Lyceo Wiskunde B Hoofdstuk 2 2 IntegraalrekeningLyceo Wiskunde B Hoofdstuk 2 2 Integraalrekening
Lyceo Wiskunde B Hoofdstuk 2 2 IntegraalrekeningLyceo Examentraining
 
Inleiding calculus 1415 les 4 gv alst
Inleiding calculus 1415 les 4 gv alstInleiding calculus 1415 les 4 gv alst
Inleiding calculus 1415 les 4 gv alstGerard van Alst
 
Inleiding matlab
Inleiding matlabInleiding matlab
Inleiding matlabtechna05
 
Cs calculus dt 1415 les 4 gv alst
Cs calculus dt 1415 les 4 gv alstCs calculus dt 1415 les 4 gv alst
Cs calculus dt 1415 les 4 gv alstGerard van Alst
 

Mais procurados (19)

Calculus
CalculusCalculus
Calculus
 
Integraalrekening 1 les 2
Integraalrekening 1 les 2Integraalrekening 1 les 2
Integraalrekening 1 les 2
 
Integraalrekening 1 les 3
Integraalrekening 1 les 3Integraalrekening 1 les 3
Integraalrekening 1 les 3
 
SQL
SQLSQL
SQL
 
Integraalrekening 1 les 5
Integraalrekening 1 les 5Integraalrekening 1 les 5
Integraalrekening 1 les 5
 
Integraalrekening 1 les 6
Integraalrekening 1 les 6Integraalrekening 1 les 6
Integraalrekening 1 les 6
 
Fis 04recursion
Fis 04recursionFis 04recursion
Fis 04recursion
 
Lyceo Wiskunde B Hoofdstuk 2 1 Differentieren
Lyceo Wiskunde B Hoofdstuk 2 1 DifferentierenLyceo Wiskunde B Hoofdstuk 2 1 Differentieren
Lyceo Wiskunde B Hoofdstuk 2 1 Differentieren
 
Integraalrekening 1 les 7
Integraalrekening 1 les 7Integraalrekening 1 les 7
Integraalrekening 1 les 7
 
Fis 02relations
Fis 02relationsFis 02relations
Fis 02relations
 
Lyceo Wiskunde B Hoofdstuk 1 1 Standaardfuncties
Lyceo Wiskunde B Hoofdstuk 1 1 StandaardfunctiesLyceo Wiskunde B Hoofdstuk 1 1 Standaardfuncties
Lyceo Wiskunde B Hoofdstuk 1 1 Standaardfuncties
 
Inleiding calculus 1415 les 7 gv alst
Inleiding calculus 1415 les 7 gv alstInleiding calculus 1415 les 7 gv alst
Inleiding calculus 1415 les 7 gv alst
 
1112 31103 05 functies in ms excel 2010-deel1
1112 31103 05  functies in ms excel 2010-deel11112 31103 05  functies in ms excel 2010-deel1
1112 31103 05 functies in ms excel 2010-deel1
 
VWO wiskunde B 2012
VWO wiskunde B 2012VWO wiskunde B 2012
VWO wiskunde B 2012
 
20130214 les gb2
20130214 les gb220130214 les gb2
20130214 les gb2
 
Lyceo Wiskunde B Hoofdstuk 2 2 Integraalrekening
Lyceo Wiskunde B Hoofdstuk 2 2 IntegraalrekeningLyceo Wiskunde B Hoofdstuk 2 2 Integraalrekening
Lyceo Wiskunde B Hoofdstuk 2 2 Integraalrekening
 
Inleiding calculus 1415 les 4 gv alst
Inleiding calculus 1415 les 4 gv alstInleiding calculus 1415 les 4 gv alst
Inleiding calculus 1415 les 4 gv alst
 
Inleiding matlab
Inleiding matlabInleiding matlab
Inleiding matlab
 
Cs calculus dt 1415 les 4 gv alst
Cs calculus dt 1415 les 4 gv alstCs calculus dt 1415 les 4 gv alst
Cs calculus dt 1415 les 4 gv alst
 

Mais de Katrien Verbert

Human-centered AI: how can we support end-users to interact with AI?
Human-centered AI: how can we support end-users to interact with AI?Human-centered AI: how can we support end-users to interact with AI?
Human-centered AI: how can we support end-users to interact with AI?Katrien Verbert
 
Human-centered AI: how can we support end-users to interact with AI?
Human-centered AI: how can we support end-users to interact with AI?Human-centered AI: how can we support end-users to interact with AI?
Human-centered AI: how can we support end-users to interact with AI?Katrien Verbert
 
Human-centered AI: how can we support lay users to understand AI?
Human-centered AI: how can we support lay users to understand AI?Human-centered AI: how can we support lay users to understand AI?
Human-centered AI: how can we support lay users to understand AI?Katrien Verbert
 
Explaining job recommendations: a human-centred perspective
Explaining job recommendations: a human-centred perspectiveExplaining job recommendations: a human-centred perspective
Explaining job recommendations: a human-centred perspectiveKatrien Verbert
 
Explaining recommendations: design implications and lessons learned
Explaining recommendations: design implications and lessons learnedExplaining recommendations: design implications and lessons learned
Explaining recommendations: design implications and lessons learnedKatrien Verbert
 
Designing Learning Analytics Dashboards: Lessons Learned
Designing Learning Analytics Dashboards: Lessons LearnedDesigning Learning Analytics Dashboards: Lessons Learned
Designing Learning Analytics Dashboards: Lessons LearnedKatrien Verbert
 
Human-centered AI: towards the next generation of interactive and adaptive ex...
Human-centered AI: towards the next generation of interactive and adaptive ex...Human-centered AI: towards the next generation of interactive and adaptive ex...
Human-centered AI: towards the next generation of interactive and adaptive ex...Katrien Verbert
 
Explainable AI for non-expert users
Explainable AI for non-expert usersExplainable AI for non-expert users
Explainable AI for non-expert usersKatrien Verbert
 
Towards the next generation of interactive and adaptive explanation methods
Towards the next generation of interactive and adaptive explanation methodsTowards the next generation of interactive and adaptive explanation methods
Towards the next generation of interactive and adaptive explanation methodsKatrien Verbert
 
Personalized food recommendations: combining recommendation, visualization an...
Personalized food recommendations: combining recommendation, visualization an...Personalized food recommendations: combining recommendation, visualization an...
Personalized food recommendations: combining recommendation, visualization an...Katrien Verbert
 
Explaining and Exploring Job Recommendations: a User-driven Approach for Inte...
Explaining and Exploring Job Recommendations: a User-driven Approach for Inte...Explaining and Exploring Job Recommendations: a User-driven Approach for Inte...
Explaining and Exploring Job Recommendations: a User-driven Approach for Inte...Katrien Verbert
 
Learning analytics for feedback at scale
Learning analytics for feedback at scaleLearning analytics for feedback at scale
Learning analytics for feedback at scaleKatrien Verbert
 
Interactive recommender systems and dashboards for learning
Interactive recommender systems and dashboards for learningInteractive recommender systems and dashboards for learning
Interactive recommender systems and dashboards for learningKatrien Verbert
 
Interactive recommender systems: opening up the “black box”
Interactive recommender systems: opening up the “black box”Interactive recommender systems: opening up the “black box”
Interactive recommender systems: opening up the “black box”Katrien Verbert
 
Interactive Recommender Systems
Interactive Recommender SystemsInteractive Recommender Systems
Interactive Recommender SystemsKatrien Verbert
 
Web Information Systems Lecture 2: HTML
Web Information Systems Lecture 2: HTMLWeb Information Systems Lecture 2: HTML
Web Information Systems Lecture 2: HTMLKatrien Verbert
 
Information Visualisation: perception and principles
Information Visualisation: perception and principlesInformation Visualisation: perception and principles
Information Visualisation: perception and principlesKatrien Verbert
 
Web Information Systems Lecture 1: Introduction
Web Information Systems Lecture 1: IntroductionWeb Information Systems Lecture 1: Introduction
Web Information Systems Lecture 1: IntroductionKatrien Verbert
 
Information Visualisation: Introduction
Information Visualisation: IntroductionInformation Visualisation: Introduction
Information Visualisation: IntroductionKatrien Verbert
 

Mais de Katrien Verbert (20)

Explainability methods
Explainability methodsExplainability methods
Explainability methods
 
Human-centered AI: how can we support end-users to interact with AI?
Human-centered AI: how can we support end-users to interact with AI?Human-centered AI: how can we support end-users to interact with AI?
Human-centered AI: how can we support end-users to interact with AI?
 
Human-centered AI: how can we support end-users to interact with AI?
Human-centered AI: how can we support end-users to interact with AI?Human-centered AI: how can we support end-users to interact with AI?
Human-centered AI: how can we support end-users to interact with AI?
 
Human-centered AI: how can we support lay users to understand AI?
Human-centered AI: how can we support lay users to understand AI?Human-centered AI: how can we support lay users to understand AI?
Human-centered AI: how can we support lay users to understand AI?
 
Explaining job recommendations: a human-centred perspective
Explaining job recommendations: a human-centred perspectiveExplaining job recommendations: a human-centred perspective
Explaining job recommendations: a human-centred perspective
 
Explaining recommendations: design implications and lessons learned
Explaining recommendations: design implications and lessons learnedExplaining recommendations: design implications and lessons learned
Explaining recommendations: design implications and lessons learned
 
Designing Learning Analytics Dashboards: Lessons Learned
Designing Learning Analytics Dashboards: Lessons LearnedDesigning Learning Analytics Dashboards: Lessons Learned
Designing Learning Analytics Dashboards: Lessons Learned
 
Human-centered AI: towards the next generation of interactive and adaptive ex...
Human-centered AI: towards the next generation of interactive and adaptive ex...Human-centered AI: towards the next generation of interactive and adaptive ex...
Human-centered AI: towards the next generation of interactive and adaptive ex...
 
Explainable AI for non-expert users
Explainable AI for non-expert usersExplainable AI for non-expert users
Explainable AI for non-expert users
 
Towards the next generation of interactive and adaptive explanation methods
Towards the next generation of interactive and adaptive explanation methodsTowards the next generation of interactive and adaptive explanation methods
Towards the next generation of interactive and adaptive explanation methods
 
Personalized food recommendations: combining recommendation, visualization an...
Personalized food recommendations: combining recommendation, visualization an...Personalized food recommendations: combining recommendation, visualization an...
Personalized food recommendations: combining recommendation, visualization an...
 
Explaining and Exploring Job Recommendations: a User-driven Approach for Inte...
Explaining and Exploring Job Recommendations: a User-driven Approach for Inte...Explaining and Exploring Job Recommendations: a User-driven Approach for Inte...
Explaining and Exploring Job Recommendations: a User-driven Approach for Inte...
 
Learning analytics for feedback at scale
Learning analytics for feedback at scaleLearning analytics for feedback at scale
Learning analytics for feedback at scale
 
Interactive recommender systems and dashboards for learning
Interactive recommender systems and dashboards for learningInteractive recommender systems and dashboards for learning
Interactive recommender systems and dashboards for learning
 
Interactive recommender systems: opening up the “black box”
Interactive recommender systems: opening up the “black box”Interactive recommender systems: opening up the “black box”
Interactive recommender systems: opening up the “black box”
 
Interactive Recommender Systems
Interactive Recommender SystemsInteractive Recommender Systems
Interactive Recommender Systems
 
Web Information Systems Lecture 2: HTML
Web Information Systems Lecture 2: HTMLWeb Information Systems Lecture 2: HTML
Web Information Systems Lecture 2: HTML
 
Information Visualisation: perception and principles
Information Visualisation: perception and principlesInformation Visualisation: perception and principles
Information Visualisation: perception and principles
 
Web Information Systems Lecture 1: Introduction
Web Information Systems Lecture 1: IntroductionWeb Information Systems Lecture 1: Introduction
Web Information Systems Lecture 1: Introduction
 
Information Visualisation: Introduction
Information Visualisation: IntroductionInformation Visualisation: Introduction
Information Visualisation: Introduction
 

gebruik van quantoren in relationele calculus

  • 1. gebruik van quantoren in relationele calculus dr. Katrien Verbert Katrien.Verbert@cs.kuleuven.be
  • 2. tupel relationele calculus •  Basisvorm: {t | formule(t)} –  t is een tupelvariabele en formule(t) een formule waarin tupelvariable t voorkomt. •  Resultaat: –  Verzameling van alle tupels t waarvoor formule(t) waar is. •  Formule bestaat uit: –  atomen + logische connectoren + quantificatoren 2
  • 3. voorbeeld •  { t | EMPLOYEE(t) and t.SALARY > 50000 } 3
  • 4. formule •  wordt uitgedrukt in predicatenlogica •  maakt gebruik van –  variabelen –  constanten –  vergelijkingsoperatoren =≠<>≥≤ –  logische connectoren ¬∧∨⇔⇒ –  quantificatie van variabelen: ∃ (er bestaat), ∀ (voor alle) 4
  • 5. voorbeeld connector constante •  { t | EMPLOYEE(t) and t.SALARY > 50000 } vergelijkingsoperator variabele 5
  • 6. quantoren •  Existentiële quantor: ∃ (er bestaat) •  Universele quantor: ∀ (voor alle) •  (∃t)(formule(t)) –  er bestaat een tupel t die aan de conditie voldoet –  bv. (∃t)(EMPLOYEE(t) and t.fname=‘John’) •  (∀t)(formule(t)) –  alle tuples in het universum voldoen aan de conditie 6
  • 7. •  Q_1 –  Geef naam en adres van alle werknemers die voor het 'Research' departement werken { t.Fname, t.Lname, t.Address | EMPLOYEE(t)                       AND (∃d) (DEPARTMENT(d)                                     AND d.Dname = 'Research’                                    AND d.Number = t.Dno) }  existentiële quantor: moet waar zijn voor tenminste één tuple we vragen werknemers op waarvoor er een gerelateerd tupel in de departement tabel bestaat met als naam ‘Research’
  • 8. gebruik van universele quantoren •  (∀x) (P(x)) –  waar als P(x) waar is voor elke x van het universum –  bv. (∀x) (x.color = “Rood”) –  betekent dat alles wat bestaat rood is •  logische implicatie –  (∀x) (Boot(x) ⇒ (x.color = “Rood”)) –  (∀x) IF Boot(x) THEN (x.color = “Rood”) –  Als x een boot is, dan moet de kleur rood zijn 8
  • 9. gebruik van universele quantoren •  ⇒ is een logische implicatie –  a ⇒ b betekent dat als a waar is, ook b waar moet zijn –  a ⇒ b is hetzelfde als ¬a ∨ b •  (∀x) (x.dnum=5 ⇒ F2) •  (∀x) IF x.dnum=5 THEN F2 •  (∀x) (not (x.dnum=5) or F2) –  x.dnum=5: F2 moet waar zijn 9
  • 10. gebruik van universele quantoren •  (∀x) (Boot(x) ⇒ (x.color = ‘Rood’)) •  ⇒ is een logische implicatie –  als x een boot is, dan moet de kleur rood zijn •  (∀x) (¬Boot(x) ∨ x.color = ‘Rood’) –  X is geen boot: conditie is waar –  X is een boot: x.color=‘Rood’ moet waar zijn 10
  • 11. –  Q_3: Geef de namen van de werknemers die aan alle projecten werken { e.Lname, e.Fname |    EMPLOYEE(e)    AND    ( (∀x) ( NOT (PROJECT(x))    OR              ( (∃w) ( WORKS_ON(w)                       AND w.Essn = e.Ssn                       AND x.Pnumber = w.Pno ) ) ) ) }   In woorden: als x een project is, dan moet er een   overeenkomsUg tupel in de works_on tabel bestaan.  11
  • 12. { e.Lname, e.Fname |    EMPLOYEE(e)    AND    ( (∀x) ( NOT (PROJECT(x))    OR              ( (∃w) ( WORKS_ON(w)                       AND w.Essn = e.Ssn                       AND x.Pnumber = w.Pno ) ) ) ) }  –  ( ∀ x ) ( F ) : •  moet voldaan zijn voor alle tuples in het universum die aan x kunnen worden toegekend –  daarom: •  ( ∀ x ) ( not PROJECT ( x ) ) •  alle tupels die niet tot PROJECT behoren uitsluiten van verdere selectievoorwaarde –  verder moet dus gelden voor een employee e dat hij werkt op elk project dat niet uitgesloten werd 12
  • 13. •  Q_6 –  Geef de namen van alle werknemers zonder personen ten laste: {e.Fname, e.Lname  |     EMPLOYEE(e) AND   ( (∀ d) ( NOT (DEPENDENT(d)) OR NOT (e.Ssn = d.Essn) ) ) } 13