theoretical computer science bridging course first order
play

Theoretical Computer Science (Bridging Course) First Order Logic - PowerPoint PPT Presentation

. . . . Theoretical Computer Science (Bridging Course) First Order Logic Gian Diego Tipaldi . Motivation Propositional logic does not allow talking about structured objects. . A famous syllogism . All men are mortal. Socrates is a


  1. . . . . Theoretical Computer Science (Bridging Course) First Order Logic Gian Diego Tipaldi

  2. . Motivation Propositional logic does not allow talking about structured objects. . A famous syllogism . All men are mortal. Socrates is a man. Therefore, Socrates is mortal. . It is impossible to formulate this in propositional logic. → first-order logic (predicate logic) 2

  3. . Elements of logic (recap) The same questions as before: Which elements are well-formed? → syntax What does it mean for a formula to be true? → semantics When does one formula follow from another? → inference We will now discuss these questions for first-order logic (but only touching the topic of inference briefly). 3

  4. . Building blocks of propositional logic In propositional logic, we can only talk about formulae (propositions). An interpretation tells us which formulae are true (or false). 4

  5. . Building blocks of first-order logic In first-order logic, there are two different kinds of elements under discussion: terms identify the object under discussion “Socrates” “the square root of 5” formulae state properties of the objects under discussion “All men are mortal.” “The square root of 5 is greater than 2.” An interpretation tells us which object is denoted by a term, and which formulae are true (or false). 5

  6. . Syntax of first-order logic: signa- tures . Definition (signature) . A (first-order) signature is a 4 -tuple S = ⟨V , C , F , R⟩ consisting of the following four (disjoint) parts: a set V of variable symbols, a set C of constant symbols, a set F of function symbols, a set R of relation symbols (also called predicate symbols) . 6

  7. . Syntax of first-order logic: signa- tures . Definition (signature) . Each function symbol f ∈ F and relation symbol R ∈ R has an associated arity (number of arguments) arity ( f ) , arity ( R ) ∈ N 1 . . Terminology: A k -ary (function or relation) symbol is a symbol s with arity ( s ) = k . Also: unary, binary, ternary 7

  8. . Syntax of first-order logic: signa- tures Conventions: variable symbols are typeset in italics , other symbols in an upright typeface relation symbols begin with upper-case letters, other symbols with lower-case letters 8

  9. . Signatures: examples . Example: arithmetic . V = { x, y, z, x 1 , x 2 , x 3 , . . . } C = { zero , one } F = { sum , product } R = { Positive , PerfectSquare } arity ( sum ) = arity ( product ) = 2 , arity ( Positive ) = arity ( PerfectSquare ) = 1 . 9

  10. . Signatures: examples . Example: genealogy . V = { x, y, z, x 1 , x 2 , x 3 , . . . } C = { queen-elizabeth , donald-duck } F = ∅ R = { Female , Male , Parent } arity ( Female ) = arity ( Male ) = 1 , arity ( Parent ) = 2 . 9

  11. . Syntax of first-order logic: terms . Definition (term) . Let S = ⟨V , C , F , R⟩ be a signature. A term (over S ) is inductively constructed according to the following rules: Each variable symbol v ∈ V is a term. Each constant symbol c ∈ C is a term. If t 1 , . . . , t k are terms and f ∈ F is a function symbol with arity k , then f ( t 1 , . . . , t k ) is a term. . 10

  12. . Syntax of first-order logic: terms Examples: x 4 donald-duck sum ( x 3 , product ( one , x 5 )) 11

  13. . Syntax of first-order logic: for- mulae . Definition (formula) . Let S = ⟨V , C , F , R⟩ be a signature. A formula (over S ) is inductively constructed as follows: R ( t 1 , . . . , t k ) (atomic formula; atom) where R ∈ R is a k -ary relation symbol and t 1 , . . . , t k are terms (over S ) (atomic formula; equality) t 1 = t 2 where t 1 and t 2 are terms (over S ) . 12

  14. . Syntax of first-order logic: for- mulae . Definition (formula) . Let S = ⟨V , C , F , R⟩ be a signature. A formula (over S ) is inductively constructed as follows: (truth) ⊤ (falseness) ⊥ (universal quantification) ∀ x ϕ (existential quantification) ∃ x ϕ where x ∈ V is a variable symbol and ϕ is a formula over S . 12

  15. . Syntax of first-order logic: for- mulae . Definition (formula) . Let S = ⟨V , C , F , R⟩ be a signature. A formula (over S ) is inductively constructed as follows: (negation) ¬ ϕ (conjunction) ( ϕ ∧ ψ ) (disjunction) ( ϕ ∨ ψ ) ( ϕ → ψ ) (material conditional) (biconditional) ( ϕ ↔ ψ ) where ϕ and ψ are formulae over S . 12

  16. . Syntax: examples . Example: arithmetic and genealogy . Positive ( x 2 ) ∀ x PerfectSquare ( x ) → Positive ( x ) ∃ x 3 PerfectSquare ( x 3 ) ∧ ¬ Positive ( x 3 ) ∀ x ( x = y ) ∀ x ( sum ( x, x ) = product ( x, one )) ∀ x ∃ y ( sum ( x, y ) = zero ) ∀ x ∃ y Parent ( y, x ) ∧ Female ( y ) . Conventions: When we omit parentheses, ∀ and ∃ bind less tightly than anything else. 13

  17. . Terminology and notation . Definition (Ground term) . Term that contains no variable symbol . Examples: zero, sum ( one , one ) , donald-duck Counterexamples: x 4 , product ( x, zero ) Similarly: ground atom, ground formula … Examples: PerfectSquare ( zero ) ∨ one = zero Counterexample: ∃ x one = x 14

  18. . Abreviations Sequences of quantifiers of the same kind can be collapsed ∀ x ∀ y ∀ z ϕ → ∀ xyz ϕ ∀ x 3 ∀ x 1 ∃ x 2 ∃ x 5 ϕ → ∀ x 3 x 1 ∃ x 2 x 5 ϕ Sometimes commas and/or colons are used: ∀ x, y, z : ϕ ∀ x 3 , x 1 ∃ x 2 , x 5 ϕ 15

  19. . Semantics of first-order logic In propositional logic, an interpretation was given by assigning values to the atomic propositions. In first-order logic, we need to interpret the meaning of constant, function and relation symbols. Variable symbols also need to be given meaning. However, this is not done through the interpretation itself, but through a separate variable assignment. 16

  20. . Semantics of first-order logic . Definition (interpretation) . An interpretation (for S ) is a pair I = ⟨ D, · I ⟩ consisting of a nonempty set D called the domain (or universe) and a function · I that assigns a meaning to constant, function and relation symbols: c I ∈ D for constant symbols c ∈ C f I : D k → D for k -ary function symbols f ∈ F R I ⊆ D k for k -ary relation symbols R ∈ R . 17

  21. . Semantics of first-order logic . Definition (variable assignment) . A variable assignment (for S and domain D ) is a function α : V → D . . Idea: extend I and α to general terms, then to atoms, then to arbitrary formulae 18

  22. . Semantics of first-order logic Example: ( ∀ x Block ( x ) → Red ( x )) ∧ Block ( a ) Terms are interpreted as objects. Unary predicates denote properties of objects (being a block, being red, …) General predicates denote relations between objects (being the child of someone, having a common multiple, …) Universally quantified formulae (“ ∀ ”) are true if they hold for all objects. Existentially quantified formulae (“ ∃ ”) are true if they hold for at least one object. 19

  23. . Interpretation in first-order logic . Definition (interpretation of a term) . Let I = ⟨ D, · I ⟩ be an interpretation for S , and let α be a variable assignment for S and domain D . Let t be a term over S . The interpretation of t under I and α , in symbols t I ,α is an element of the domain D defined as follows: If t = x with x ∈ V ( t is a variable term): x I ,α = α ( x ) . 20

  24. . Interpretation in first-order logic . Definition (interpretation of a term) . Let I = ⟨ D, · I ⟩ be an interpretation for S , and let α be a variable assignment for S and domain D . Let t be a term over S . The interpretation of t under I and α , in symbols t I ,α is an element of the domain D defined as follows: If t = c with c ∈ C ( t is a constant term): c I ,α = c I . 20

  25. . Interpretation in first-order logic . Definition (interpretation of a term) . Let I = ⟨ D, · I ⟩ be an interpretation for S , and let α be a variable assignment for S and domain D . Let t be a term over S . The interpretation of t under I and α , in symbols t I ,α is an element of the domain D defined as follows: If t = f ( t 1 , . . . , t k ) ( t is a function term): ( f ( t 1 , . . . , t k )) I ,α = f I ( t I ,α 1 , . . . , t I ,α k ) . 20

  26. with zero one sum product . mod mod Interpreting terms: example Signature: S = ⟨V , C , F , R⟩ with V = { x, y, z } , C = { zero , one } F = { sum , product } , arity ( sum ) = arity ( product ) = 2 21

  27. . Interpreting terms: example Signature: S = ⟨V , C , F , R⟩ with V = { x, y, z } , C = { zero , one } F = { sum , product } , arity ( sum ) = arity ( product ) = 2 I = ⟨ D, · I ⟩ with D = { d 0 , d 1 , d 2 , d 3 , d 4 , d 5 , d 6 } zero I = d 0 one I = d 1 sum I ( d i , d j ) = d ( i + j ) mod 7 , ∀ i, j ∈ { 0 , . . . , 6 } product I ( d i , d j ) = d ( i · j ) mod 7 ∀ i, j ∈ { 0 , . . . , 6 } α = { x �→ d 5 , y �→ d 5 , z �→ d 0 } 21

  28. . Interpreting terms: example . Example (ctd.) . zero I ,α = y I ,α = sum ( x, y ) I ,α = product ( one , sum ( x, zero )) I ,α = . 22

  29. . Satisfaction in first-order logic . Definition (satisfaction of a formula) . Let I = ⟨ D, · I ⟩ be an interpretation for S , and let α be a variable assignment for S and domain D . We say that I and α satisfy a first-order logic formula ϕ (also: ϕ is true under I and α ), in symbols: I , α | = ϕ , according to the following inductive rules: = R ( t 1 , . . . , t k ) iff ⟨ t I ,α 1 , . . . , t I ,α k ⟩ ∈ R I I , α | iff t I ,α = t I ,α I , α | = t 1 = t 2 . 1 2 23

Recommend


More recommend