1 / 9

Predicate Calculus

Predicate Calculus. Formal language True/False statements Supports reasoning Usage Integrity constraints Non-procedural query languages “what” rather than “how” SQL (helps with formulation of some harder queries) Prolog Model theory (basis for design theory, techniques & tools).

amelia
Download Presentation

Predicate Calculus

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Predicate Calculus • Formal language • True/False statements • Supports reasoning • Usage • Integrity constraints • Non-procedural query languages • “what” rather than “how” • SQL (helps with formulation of some harder queries) • Prolog • Model theory (basis for design theory, techniques & tools)

  2. Syntax – Symbols • Truth Values: T F • Constants • Variables • Functions: return a value • Predicates: return T or F • Logical Connectors • Quantifiers:  • xP(x) = P(x1)  P(x2)  … • xP(x) = P(x1)  P(x2)  ... • Parentheses P Q P PQ PQ PQ PQ F F T F F T T F T T F T T F T F F F T F F T T F T T T T

  3. Syntax – Terms & Atoms • Terms: yield a value • Each variable and constant is a term. • Each function is a term (e.g., f(t1, t2) where t1 and t2 are terms). • Atoms: yield T or F • T • F • Each predicate is an atom (e.g., p(t1, t2) where t1 and t2 are terms).

  4. Syntax – Formulas • Formulas • An atom is a formula. • If P & Q are formulas, so are (P), (PQ), (PQ), (PQ), (PQ) • If P is a formula and x is a variable, x(P) and x(P) are formulas • Example: x(x+y = 10  zx(x > z)) • bound and free variables • scope of a variable • closed and open formulas

  5. Semantics • Interpretation • Specify domain D • Assign values in D to: • Constants (unique name assumption: literals denote themselves & constant symbols like  have only one value) • n-ary functions: f:Dn D (e.g., +, -, …) • n-ary predicates: p:Dn {T, F} (e.g., <, =, …) • Evaluation • Closed formulas: evaluation yields T or F • Open formulas: evaluation yields set of domain elements • Examples • D = {0, …, 99} • x(2x mod 100 > 95) evaluates to T • x(2x mod 100 > 95) evaluates to F • 2x mod 100 > 95 yields {48, 49, 98, 99}

  6. Counting Quantifiers • Notational shorthand • 1x(P(x)) T if there is exactly 1 value for which P is true • 2x(P(x)) … exactly 2 … • 5x(P(x)) … 5 or more … • <3x(P(x)) … less than 3 … • Equivalent expressions • 0x(P(x)) x(P(x))  x(P(x)) • 1x(P(x))  x(P(x))  xy(P(x)  P(y)  x = y)

  7. Model Theory & Relational DBs • Let relation names be predicates with a place for each attribute. • Write integrity constraints as closed formulas. • Example: Interpretation: Domain = {1,2,3} r(1, 2, 3) = T r(2, 2, 2) = T r(x, y, z) = F (for all others) x1<y, z>(r(x, y, z)) r(A, B, C) 1 2 3 2 2 2 A is a Key.

  8. Model Theory, OSM, & Rel. DBs Room(x) has Cost(y) Cost(x) is equivalent to Amount(y) in Currency(z) R1 90 90 99 CHF R2 80 90 8,781 Yen R3 80 80 89 CHF 80 7,807 Yen • Relations: • Integrity Constraints: • Key Constraints • x1y(Room(x) has Cost(y)) • xy1z(Cost(x) is equivalent to Amount(z) in Currency(y)) • xy1z(Cost(z) is equivalent to Amount(x) in Currency(y)) • Referential-Integrity Constraints • xyz(Cost(x) is equivalent to Amount(y) in Currency(z) w(Room(w) has Cost(x))) • Attribute-Domain Constraints • x(yz(Cost(y) is equivalent to Amount(z) in Currency(x)  x  {CHF,Yen, …}) • ...

  9. Valid Interpretations • Interpretation • Domain • all values in the current DB • domain-closure assumption: these are the only elements that can be substituted for variables • Value Assignments • assign constants to themselves • use the closed-world assumption (tuple substitutions for predicates yield T, and all other substitutions yield F) • Valid Interpretation • All closed formulas evaluate to T • DB integrity: the constraints of the DB are satisfied • Examples: the previous two examples show valid interpretations

More Related