Discrete Mathematics(ID) Spring 2013 Lecture 12: Term Formula and formation tree 1 Overview In the last lecture, predicates, variables, constants, functions and quantifiers are introduced to enhance the capability of logic to express much rich sentences. In this lecture, we will discuss the form of predicate logic in the view of point of syntax 2 Term Term has been defined in the last lecture. It includes constant variable and function. As function can be nested, a very complicated term could be constructed 3 Formula Formula is a sequence of symbols of predicated language formed following a specific rules. Similar to proposition logic, we here also introduce subformula to further investigate formula Definition 1(Subformula). A subformula of a formula p is a consecutive sequence of symbols from y which is itself a formula. onsager ollowing exam Example 1. Given an 1. Is((Va)p(ar)a subformula? 2. Is a() a subformula? 3.((Va)((a)vo(a, g)),(x)o(a)), p(a), o(a, y), and o(z)all are subformulas Here, we should pay attention to consecutive. Otherwise, we could take some subsequence wrong as a subformula. Obviously, the first one is not a subformula for it is not a consecutive sub-sequence of the given formula. However, the second one is something special, which depends how rigorous ou apply definition Let's consider the following examples Example 2. Given the following formulas 1.((x)y(x,y)A(x)v(x)
Discrete Mathematics (II) Spring 2013 Lecture 12: Term, Formula and Formation Tree Lecturer: Yi Li 1 Overview In the last lecture, predicates, variables, constants, functions and quantifiers are introduced to enhance the capability of logic to express much rich sentences. In this lecture, we will discuss the form of predicate logic in the view of point of syntax. 2 Term Term has been defined in the last lecture. It includes constant, variable, and function. As function can be nested, a very complicated term could be constructed. 3 Formula Formula is a sequence of symbols of predicated language formed following a specific rules. Similar to proposition logic, we here also introduce subformula to further investigate formula. Definition 1 (Subformula). A subformula of a formula φ is a consecutive sequence of symbols from φ which is itself a formula. Consider the following example. Example 1. Given an formula (((∀x)(φ(x) ∨ ϕ(x, y))) → ((∃z)σ(z))). 1. Is ((∀x)φ(x)) a subformula? 2. Is σ(x) a subformula? 3. ((∀x)(φ(x) ∨ ϕ(x, y))), ((∃z)σ(z)),φ(x), ϕ(x, y), and σ(z) all are subformulas. Here, we should pay attention to consecutive. Otherwise, we could take some subsequence wrong as a subformula. Obviously, the first one is not a subformula for it is not a consecutive sub-sequence of the given formula. However, the second one is something special, which depends how rigorous you apply definition. Let’s consider the following examples. Example 2. Given the following formulas: 1. (((∀x)φ(x, y)) ∧ ((∃x)ψ(x))) 1
2.(((Va)o(a, y))Av(a) We have observed that some variable r has relation with a quantifier(V r)or r) In order to discuss the relation between variables and quantifiers, we have the following definition Definition 2(Occurrence). An occurrence of a variable v in a formula p is bound if there is a subformula y of p containing that occurrence of v such that w begins with(Vu) or(v). An occurrence of v in p is free if it is not bound Here, we should pay attention to each occurrence in the definition Definition 3. A variable v is said to occur free in p if it has at least one free occurrence there However, if we say a variable is free if it take place free once Consider the following examples Example 3. Given a formula 1.(y(r)p(, u))Av(r)) It is obvious that r is free for the first occurrence is bound and the second is free We have some special formulas. Consider the following example Example 4. Please observe the following formulas 1.((y((Var)p(a, y))A(Va)(a)) 2.((Va)(((yR(, y))v(yT(a, y))) We can find a common feature that there is no free occurrence of any variable. Definition 4. A sentence of predicate logic is a formula with no free occurrences of any variable In the most of cases, we only discuss sentences Contrary to sentence, we have another form of special formulas Definition 5. An open formula is a formula without quantifi Consider the following example Example 5. 1. All atomic formulas: o(a), R(a, y) 2.(R(, y)vo())
2. (((∀x)φ(x, y)) ∧ ψ(x)) We have observed that some variable x has relation with a quantifier (∀x) or (∃x). In order to discuss the relation between variables and quantifiers, we have the following definition. Definition 2 (Occurrence). An occurrence of a variable v in a formula φ is bound if there is a subformula ψ of φ containing that occurrence of v such that ψ begins with ((∀v) or ((∃v). An occurrence of v in φ is free if it is not bound. Here, we should pay attention to each occurrence in the definition. Definition 3. A variable v is said to occur free in φ if it has at least one free occurrence there. However, if we say a variable is free if it take place free once. Consider the following examples: Example 3. Given a formula: 1. ((∃y)((∀x)φ(x, y)) ∧ ψ(x)) It is obvious that x is free for the first occurrence is bound and the second is free. We have some special formulas. Consider the following example. Example 4. Please observe the following formulas: 1. ((∃y)((∀x)φ(x, y)) ∧ (∀z)ψ(z)) 2. ((∀x)(((∀y)R(x, y)) ∨ ((∃y)T(x, y))). 3. φ(c0, c1) We can find a common feature that there is no free occurrence of any variable. Definition 4. A sentence of predicate logic is a formula with no free occurrences of any variable. In the most of cases, we only discuss sentences. Contrary to sentence, we have another form of special formulas. Definition 5. An open formula is a formula without quantifiers . Consider the following example. Example 5. 1. All atomic formulas: ϕ(x), R(x, y) .... 2. (R(x, y) ∨ ϕ(x)). 3. R(c0, c1). 2
In some case, we may substitute a variable with another term Definition 6(Substitution(Instantiation)). If p is a formula and v a variable, we write (u) to denote the fact that v occurs free in pp 1. Ift is a term, then o(t), or if we wish to be more explicit, p(u/t), is the result of substituting C or instantiating) t for all free occurrences of v in y. We call p(t) an instance of o 2. If p(t) contains no free variables, we call it a ground instance of p Consider the following example Example 6. Given a formula((var(, y))v(yS(a, y)) 1. It is denoted as p(, y) 2. p(a/s, y/t)=((Vr)R(a, t))V(y)S(s, y)) 3. (a/c, y/d)=((V)R(, d))v(y)S(c, y)) Generally, we have the following rules Example 7. The recursive definition of p(a/t)with substitution to. The recursive definition of to 1. t is a constant, t[r/to 2. t is a ta/to= to if 0.(t≠x) 3.t=g(t1,t2,,tk), ta/to]=g(ti[r/to], t2[a/to,., tk[/to) 4. p(a, y) is an atomic formula, p(/to=p(to, y) 5 9=9 [/to]=pllc/]Dp2[c/to (a, y)=Q2(, 3, 2) pla/tol Q2(vlr/to) Consider the following substitution Example 8. Given a formula p(a)=y)(a +y=0) and s(a)=a+l. Consider the substitution p(a/s(y)). We just assume that both variables are integers
In some case, we may substitute a variable with another term. Definition 6 (Substitution(Instantiation)). If φ is a formula and v a variable, we write φ(v) to denote the fact that v occurs free in φ. 1. If t is a term, then φ(t), or if we wish to be more explicit, φ(v/t), is the result of substituting ( or instantiating) t for all free occurrences of v in φ. We call φ(t) an instance of φ. 2. If φ(t) contains no free variables, we call it a ground instance of φ. Consider the following example. Example 6. Given a formula ((∀x)R(x, y)) ∨ ((∃y)S(x, y)), 1. It is denoted as φ(x, y). 2. φ(x/s, y/t) = ((∀x)R(x, t)) ∨ ((∃y)S(s, y)). 3. φ(x/c, y/d) = ((∀x)R(x, d)) ∨ ((∃y)S(c, y)). Generally, we have the following rules. Example 7. The recursive definition of φ(x/t) with substitution t0. The recursive definition of t0 to x in t. 1. t is a constant, t[x/t0] = t 2. t is a variable, t[x/t0] = { t0 if t = x t o.w. (t ̸= x) 3. t = g(t1, t2, . . . , tk), t[x/t0] = g(t1[x/t0], t2[x/t0], . . . , tk[x/t0]) 4. φ(x, y) is an atomic formula, φ[x/t0] = φ(t0, y) 5. φ = ¬ψ, φ[x/t0] = ¬ψ[x/t0] 6. φ = φ1□φ2, φ[x/t0] = φ1[x/t0]□φ2[x/t0] 7. φ(x, y) = Qzψ(x, y, z), φ[x/t0] = { φ, x = z Qz(ψ[x/t0]), x ̸= z Consider the following substitution. Example 8. Given a formula φ(x) = (∃y)(x + y = 0) and s(x) = x + 1. Consider the substitution φ(x/s(y)). We just assume that both variables are integers. 3
It is obvious that it is wrong after substitution However, some substitution is not correct in the point of view of semantic. We have the following definition Definition 7. If the term t contains an occurrence of some variable a(which is necessarily free in t) we say that t is substitutable for the free variable v in lu) if all occurrences of a in t remain ee in ((u onsider tne Example 9. Let p(a)=(((yR(a, u))V((Vz)Q(a, a)) 1.Ift= f(w, u), then we have p(t)=p(a/t)=(((yR((w, u), y))V((Vz)Q(f(w, u), a))) 2. Ift= g(y, s()), it is not substitutable for in p(a) Proposition 8. If a term s is an initial segment of a term t, s Ct, then s=t Theorem 9(Unique readability for terms). Every term s is either a variable or constant symb or of the form f(s1, .. Sn)in which case f, n and the si for 1<isn are all unique determined Proposition 10. If a formula a is an initial segment of a formula 1, a C?, then a=? Theorem 11 (Unique readability for formulas ). Each formula o is a precisely one of the following forms: an atomic formula,(aAB),o,B),a+ B), a),(aV B. Moreover, the relevant components"of o as displayed in each of these formula are uniquely determined 4 Formation tree Definition 12. 1. Term formation trees are ordered, finitely branching tree T labeled with terms satisfying the following condition (a) The leaves of T are labeled with variables of constant symbols (b) each nonleaf node of T is labeled with a term of the form f(t1,., tn) (c) A node of t that is labeled with a term of the form f(t1, .. tn) has exactly n immediate successors in the tree. They are labeled in(lexicographic) order with t1,...,t, 2. A term formation tree is associated with the term with which its root node is labeled. Proposition 13. Every term t has a unique formation tree associated with it Proposition 14. The ground terms are those terms whose formation trees have no variables on their leaves Definition 15. The atomic formula auxiliary formation trees are the labeled, ordered, finitely branching trees of depth one whose root node is labeled with an atomic formula. If th e root node such a tree is labeled with an n-ary relation r(t1,., tn), then it has n immediate successor which are labeled in order with the terms tu, .. tn
It is obvious that it is wrong after substitution. However, some substitution is not correct in the point of view of semantic. We have the following definition. Definition 7. If the term t contains an occurrence of some variable x (which is necessarily free in t) we say that t is substitutable for the free variable v in φ(v) if all occurrences of x in t remain free in φ(v/t). Consider the following example. Example 9. Let φ(x) = (((∃y)R(x, y)) ∨ ((∀z)¬Q(x, z))). 1. If t = f(w, u), then we have φ(t) = φ(x/t) = (((∃y)R(f(w, u), y)) ∨ ((∀z)¬Q(f(w, u), z))). 2. If t = g(y, s(y)), it is not substitutable for x in φ(x). Proposition 8. If a term s is an initial segment of a term t, s ⊆ t, then s = t. Theorem 9 (Unique readability for terms). Every term s is either a variable or constant symbol or of the form f(s1, . . . , sn) in which case f, n and the si for 1 ≤ i ≤ n are all unique determined. Proposition 10. If a formula α is an initial segment of a formula γ, α ⊂ γ, then α = γ. Theorem 11 (Unique readability for formulas). Each formula ϕ is a precisely one of the following forms: an atomic formula, (α ∧ β),(α → β),(α ↔ β),(¬α),(α ∨ β). Moreover, the relevant ”components” of ϕ as displayed in each of these formula are uniquely determined. 4 Formation tree Definition 12. 1. Term formation trees are ordered, finitely branching tree T labeled with terms satisfying the following conditions: (a) The leaves of T are labeled with variables of constant symbols. (b) Each nonleaf node of T is labeled with a term of the form f(t1, . . . , tn). (c) A node of T that is labeled with a term of the form f(t1, . . . , tn) has exactly n immediate successors in the tree. They are labeled in (lexicographic) order with t1, . . . , tn. 2. A term formation tree is associated with the term with which its root node is labeled. Proposition 13. Every term t has a unique formation tree associated with it. Proposition 14. The ground terms are those terms whose formation trees have no variables on their leaves. Definition 15. The atomic formula auxiliary formation trees are the labeled , ordered, finitely branching trees of depth one whose root node is labeled with an atomic formula. If the root node of such a tree is labeled with an n-ary relation R(t1, . . . , tn), then it has n immediate successor which are labeled in order with the terms t1, . . . , tn. 4
Definition 16. The atomic formula formation trees are the finitely branching, labeled, ordered trees gotten from the auxiliary trees by attaching at each leaf labeled with a term the rest of the formation tree associated with t. Such a tree is associated with the atomic formula with which its root is labeled Proposition 17. Every atomic formula is associated with a unique formation tree Definition 18. The formula auxiliary formation trees are the labeled, ordered, binary branching trees T such that 1. The leaves of f are labeled with atomic formulas 2. If o is a nonleaf node of T with one immediate successor oo labeled writh a formula then g is labeled with mp, 3up, or Vup for some variable v 3. If o is a nonleaf node with two immediate successors, o A0 and o A l labeled with formulas sp and y, then g is labeled withφ∧v,φ∨v,φ→v,φ分v Definition 19. 1. The formula formation trees are the ordered, labeled trees gotten from the auciliary ones by attaching to each leaf labeled with an atomic formula the rest of its associated formation tree. Each such tree is again associated with the formula with which its root is 2. The depth of a formula is the depth of the associated auxiliary formation tree. Proposition 20. Every formula is associated with a unique(auxiliary) formation tree Proposition 21. The subformulas of a formula o are the labels of the nodes of the auciliary formation tree associated with Proposition 22. 1. The occurrences of a variable v in a formula p are in one-one correspon dence with the leaves of the associated formation tree that are labeled with v. We may also refer to the appropriate leaf labeled with v as the occurrence of v in 2. An occurrence of the variable v in p is bound if there is a formula o beginning with((vu)or(v) which is the label of a node above the corresponding leaf of the formation tree for p labeled th u Proposition 23. If p is a formula and v a variable, then (u/t)is the formula associated with e formation tree gotten by replacing each leaf in the tree for o u which is labeled with a free occurrence of v with the formation tree associated with t and propagating this change through the Proposition 24. The term t is substitutable for v in o(u) if all occurrences of a in t remain free in (t),i. e, any leaf in the formation tree for t which is a free occurrence of a variable a remains in every location in which it appears in the formation tree described in Definition 3.8 5 Parsing algorithm With help of formation tree, we could parse a formula in a relative way. As the definition is an expansion of definition of proposition by introducing variable, function, predicates, and quantifiers
Definition 16. The atomic formula formation trees are the finitely branching, labeled, ordered trees gotten from the auxiliary trees by attaching at each leaf labeled with a term the rest of the formation tree associated with t. Such a tree is associated with the atomic formula with which its root is labeled. Proposition 17. Every atomic formula is associated with a unique formation tree. Definition 18. The formula auxiliary formation trees are the labeled, ordered, binary branching trees T such that 1. The leaves of T are labeled with atomic formulas. 2. If σ is a nonleaf node of T with one immediate successor σ ∧ 0 labeled with a formula φ, then σ is labeled with ¬φ, ∃vφ, or ∀vφ for some variable v. 3. If σ is a nonleaf node with two immediate successors, σ ∧ 0 and σ ∧ 1 labeled with formulas φ and ψ, then σ is labeled with φ ∧ ψ, φ ∨ ψ, φ → ψ, φ ↔ ψ. Definition 19. 1. The formula formation trees are the ordered, labeled trees gotten from the auxiliary ones by attaching to each leaf labeled with an atomic formula the rest of its associated formation tree. Each such tree is again associated with the formula with which its root is labeled. 2. The depth of a formula is the depth of the associated auxiliary formation tree. Proposition 20. Every formula is associated with a unique(auxiliary) formation tree. Proposition 21. The subformulas of a formula φ are the labels of the nodes of the auxiliary formation tree associated with φ. Proposition 22. 1. The occurrences of a variable v in a formula φ are in one-one correspondence with the leaves of the associated formation tree that are labeled with v. We may also refer to the appropriate leaf labeled with v as the occurrence of v in φ. 2. An occurrence of the variable v in φ is bound if there is a formula ϕ beginning with ((∀v) or ((∃v) which is the label of a node above the corresponding leaf of the formation tree for φ labeled with v. Proposition 23. If φ is a formula and v a variable, then φ(v/t) is the formula associated with the formation tree gotten by replacing each leaf in the tree for φ(v) which is labeled with a free occurrence of v with the formation tree associated with t and propagating this change through the tree. Proposition 24. The term t is substitutable for v in φ(v) if all occurrences of x in t remain free in φ(t), i.e., any leaf in the formation tree for t which is a free occurrence of a variable x remains in every location in which it appears in the formation tree described in Definition 3.8. 5 Parsing Algorithm With help of formation tree, we could parse a formula in a relative way. As the definition is an expansion of definition of proposition by introducing variable, function, predicates, and quantifiers. 5
Correspondingly, we can also extend parsing algorithm of proposition to recognize a formula in a direct approach. We first introduce a parsing subroutine for a general term and a atomic formula in the same way. And we then extend proposition's parsing algorithm to recognize a general formula which is left as an exercise Exercises 1. Given formulas in Ex 2(c),(e), (f)on page 88. Which occurrences of variables are free? Which 2. Ex 5(b, c)/ page 88 3. Ex 2(d, e)/ page 94 4. Ex 13/ page 95 5. Design an algorithm to make a substitution 6. Augment parsing algorithm for proposition logic to recognize a formula of predicate logic Here, we assume that predicates, functions, variables, and constants are represented by
Correspondingly, we can also extend parsing algorithm of proposition to recognize a formula in a direct approach. We first introduce a parsing subroutine for a general term and a atomic formula in the same way. And we then extend proposition’s parsing algorithm to recognize a general formula, which is left as an exercise. Exercises 1. Given formulas in Ex 2 (c),(e),(f) on page 88. Which occurrences of variables are free? Which are bound? 2. Ex 5(b, c)/ page 88. 3. Ex 2(d, e)/ page 94. 4. Ex 13/ page 95. 5. Design an algorithm to make a substitution. 6. Augment parsing algorithm for proposition logic to recognize a formula of predicate logic. Here, we assume that predicates, functions, variables, and constants are represented by a single symbol. 6