当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

复旦大学:《离散数学 Discrete Mathematics》英文讲义_05 Formation Tree and Parsing Algorithm

资源类别:文库,文档格式:PDF,文档页数:6,文件大小:143.5KB,团购合买
点击下载完整版文档(PDF)

Discrete Mathematics(II) Spring 2012 Lecture 5: Formation Tree and Parsing algorith Lecturer. yil 1 Overview In this lecture, we completely focus on syntax of proposition. And the term "proposition"does always mean well-defined proposition without explicit declaration The most important topic is to make sure the unique readability of a well defined proposition. And then a proposition is associated with a tree, called formation tree. Therefore, we find the properties of a well-defined proposition based on its tree form. Finally, we introduce a parsing algorithm to check the validity of a sequence of symbols, with a formation tree as a by-product 2 Some properties of proposition 2.1 Ambiguity In everyday language, we sometimes could speak some sentence which could be understood totally ith different meaning, which is called ambiguous Example 1. Consider the following sentences 1. The lady hit the man with an umbrella 2. He gave her cat food 3. They are looking for teachers of French, German and Japanese Once you read these sentences, you way wonder 1. Is the lady using an umbrella to hit or is she hitting a man who is carrying an umbrella? 2. Is he giving cat food to her or is he giving her cat some food? 3. Are they looking for teachers who can each teach one language or all three languages? You may find more examples. Here, the ambiguity is not caused by the meaning/ semantics of some word. The reason is just the way to group words in different approaches Similarly, you could encounter the same trouble when you write a piece of segment of code. The example is the way to nest if and else. You can also consider the following expression4/ 2 x 2 Without the help of parentheses, proposition could also run into the same problem. Consider the following example

Discrete Mathematics (II) Spring 2012 Lecture 5: Formation Tree and Parsing Algorithm Lecturer: Yi Li 1 Overview In this lecture, we completely focus on syntax of proposition. And the term “proposition” does always mean well-defined proposition without explicit declaration. The most important topic is to make sure the unique readability of a well defined proposition. And then a proposition is associated with a tree, called formation tree. Therefore, we find the properties of a well-defined proposition based on its tree form. Finally, we introduce a parsing algorithm to check the validity of a sequence of symbols, with a formation tree as a by-product. 2 Some properties of proposition 2.1 Ambiguity In everyday language, we sometimes could speak some sentence which could be understood totally with different meaning, which is called ambiguous. Example 1. Consider the following sentences: 1. The lady hit the man with an umbrella. 2. He gave her cat food. 3. They are looking for teachers of French, German and Japanese. Once you read these sentences, you way wonder: 1. Is the lady using an umbrella to hit or is she hitting a man who is carrying an umbrella? 2. Is he giving cat food to her or is he giving her cat some food? 3. Are they looking for teachers who can each teach one language or all three languages? You may find more examples. Here, the ambiguity is not caused by the meaning/semantics of some word. The reason is just the way to group words in different approaches. Similarly, you could encounter the same trouble when you write a piece of segment of code. The example is the way to nest if and else. You can also consider the following expression “4/2 × 2”. Without the help of parentheses, proposition could also run into the same problem. Consider the following example. 1

Example 2. Consider the following proposition A1VA2∧A which is definitely not well-defined Solution. We have two possible different propositions 1.(A1VA2)∧A3 2.A1V(A2∧A3) Of course, they have different abbrevation truth tables Mathematics is rigid. One of the responsibilities of mathematical logic is to eliminate ambiguity from mathematics. So we should first eliminate ambiguity in mathematical logic 2.2 Parent Theorem 1. Every well-defined proposition has the same number of left as right parentheses Proof. Consider the symbols without parentheses first And then prove it by induction with more complicated propositions according to the construction of a complicated propositio Here, we actually use the depth of nested connectives, which will be introduced in the next section Theorem 2. Any proper initial segement of a well defined proposition contains an excess of left parenthesis. Thus no proper initial segement of a well defined propositon can itself be a well defined propositions Go back to lecture three if your forget what is a proper initial segment Proof. Prove it by induction from simple to complicated propositions. And we also need Theorem 1 3 Formation tree A proposition is a sequence of symbols. The structure determines the reading of a proposition. In this section, we are to map a proposition to a tree, named formation tree. It will help us to read a proposition Definition 3(Top-down). A formation tree is a finite tree T of binary sequences whose nodes are all labele with propositions. The labeling satisfies the following conditions

Example 2. Consider the following proposition A1 ∨ A2 ∧ A3, which is definitely not well-defined. Solution. We have two possible different propositions 1. (A1 ∨ A2) ∧ A3 2. A1 ∨ (A2 ∧ A3) Of course, they have different abbrevation truth tables. Mathematics is rigid. One of the responsibilities of mathematical logic is to eliminate ambiguity from mathematics. So we should first eliminate ambiguity in mathematical logic. 2.2 Parentheses Theorem 1. Every well-defined proposition has the same number of left as right parentheses. Proof. Consider the symbols without parentheses first. And then prove it by induction with more complicated propositions according to the construction of a complicated proposition. Here, we actually use the depth of nested connectives, which will be introduced in the next section. Theorem 2. Any proper initial segement of a well defined proposition contains an excess of left parenthesiss. Thus no proper initial segement of a well defined propositon can itself be a well defined propositions. Go back to lecture three if your forget what is a proper initial segment. Proof. Prove it by induction from simple to complicated propositions. And we also need Theorem 1. 3 Formation Tree A proposition is a sequence of symbols. The structure determines the reading of a proposition. In this section, we are to map a proposition to a tree, named formation tree. It will help us to read a proposition. Definition 3 (Top-down). A formation tree is a finite tree T of binary sequences whose nodes are all labele with propositions. The labeling satisfies the following conditions: 2

1. The leaves are labeled with propositional letters 2. if a node o is labeled with a proposition of the form(avB),(anB),a,B)or(a+ B), its immediate successors, o0 and o 1, are labeled with a and B (in that order) if a node o is labeled with a proposition of the form(a), its unique immediate successor, g0 is labeled with a How to map a well-defined proposition to a tree? Consider the following example Example3. The formation tree of(AVB),(A∧B)→C) It is easy to draw its formation tree for this example. However, when a proposition is complicated enough, it is not easy. Just rethink your approach. We may follow the procedure of constructing a proposition from a propositional letters in a bottom-up way, even we define it in a top-down approach These two examples are specified. What about the other propositions? Given proposition, we have the following questions 1. Is there a formation tree? 2. Is it unique? It is lucky that we have the following Theorem Theorem 4. Each well-defined proposition has a unique formation tree associated with it Proof.(Sketch) 1. Existence of the formation tree by induction on depth 2. Uniqueness of the formation tree by induction on depth From now on, we sometimes call the labeled tree of a proposition associated formation tree Once we have formation tree of a proposition, we can define these following terms Definition 5. Given an associated formation tree, we have 1. The depth of a proposition is the depth of associated formation tree 2. The support of a proposition is the set of propositional letters that occur as labels of the leaves of the associated formation tree Actually, all inductive proof could be based on the depth of a proposition

1. The leaves are labeled with propositional letters. 2. if a node σ is labeled with a proposition of the form (α ∨ β),(α ∧ β),(α → β) or (α ↔ β), its immediate successors, σˆ0 and σˆ1, are labeled with α and β (in that order). 3. if a node σ is labeled with a proposition of the form (¬α), its unique immediate successor, σˆ0, is labeled with α. How to map a well-defined proposition to a tree? Consider the following example. Example 3. The formation tree of (A ∨ B),((A ∧ B) → C) . It is easy to draw its formation tree for this example. However, when a proposition is complicated enough, it is not easy. Just rethink your approach. We may follow the procedure of constructing a proposition from a propositional letters in a bottom-up way, even we define it in a top-down approach. These two examples are specified. What about the other propositions? Given proposition, we have the following questions: 1. Is there a formation tree? 2. Is it unique? It is lucky that we have the following Theorem. Theorem 4. Each well-defined proposition has a unique formation tree associated with it. Proof. (Sketch) 1. Existence of the formation tree by induction on depth. 2. Uniqueness of the formation tree by induction on depth. From now on, we sometimes call the labeled tree of a proposition associated formation tree. Once we have formation tree of a proposition, we can define these following terms. Definition 5. Given an associated formation tree, we have 1. The depth of a proposition is the depth of associated formation tree. 2. The support of a proposition is the set of propositional letters that occur as labels of the leaves of the associated formation tree. Actually, all inductive proof could be based on the depth of a proposition. 3

4 Parsing There are infinitely many sequence of symbols. How to identify which is well-defined and which is not? If we want to build a proof system executed on a computer it is very important to construct first a method to check whether it is valid or not 4.1 Algorithm As a well-defined proposition can be uniquely mapped into a formation tree, which is easy to check every node well-defined or not. We can now introduce a recursive algorith to analyze sequence of symbols 1. If all leaf nodes are labeled with proposition letters, stop it. Otherwise select a leaf node having expressions other than letter and examine it 2. The first symbol must be(. if the second symbol is " jump to step 4. Otherwise go to step 3.(a)Scan the expression from the left until first reaching(a, where a is a nonempty expression a balance between( and (b The a is the first of the two constituents. (c) The next symbol must be∧,V,→,or+ (d)The remainder of the expression, B)must consist of a an expression B and (e) Extend the tree by adding a and B as left and right immediate successor respectively 4. The first two symbols are now known to be(. The remainder of the expression, B)must consist of a an expression B and ). Then we extend the tree by adding B as its immediate successor. Goto step 1 In algorithm, we omit the procedure to exit for sequence which is not well-defined. Check every node, if a internal node is not well defined or terminal node is not a proposition letter, the algorithm just stops and asserts a non-well-defined sequence What's most important is that the algorithm checks the sequence recursively. It is the similar to the approach to define a well-defined proposition 4.2 Parentheses Parentheses are tedious for us to handle, We can introduce some rule to reduce the number of parentheses without ambiguity 1. The outermost parenthesis need not be explicitly mentioned 2. The negation symbol applies to as little as possible 3. The conjuction and disjunction symbols apply to as little as possible

4 Parsing There are infinitely many sequence of symbols. How to identify which is well-defined and which is not? If we want to build a proof system executed on a computer it is very important to construct first a method to check whether it is valid or not. 4.1 Algorithm As a well-defined propostition can be uniquely mapped into a formation tree, which is easy to check every node well-defined or not. We can now introduce a reacursive algorith to analyze sequence of symbols. 1. If all leaf nodes are labeled with proposition letters, stop it. Otherwise select a leaf node having expressions other than letter and examine it. 2. The first symbol must be (. if the second symbol is ¬, jump to step 4. Otherwise go to step 3. 3. (a) Scan the expression from the left until first reaching (α, where α is a nonempty expression having a balance between ( and ). (b) The α is the first of the two constituents. (c) The next symbol must be ∧, ∨, →, or ↔. (d) The remainder of the expression, β) must consist of a an expression β and ). (e) Extend the tree by adding α and β as left and right immediate successor respectively. 4. The first two symbols are now known to be (¬. The remainder of the expression, β) must consist of a an expression β and ). Then we extend the tree by adding β as its immediate successor. Goto step 1. In algorithm, we omit the procedure to exit for sequence which is not well-defined. Check every node, if a internal node is not well defined or terminal node is not a proposition letter, the algorithm just stops and asserts a non-well-defined sequence. What’s most important is that the algorithm checks the sequence recursively. It is the similar to the approach to define a well-defined proposition. 4.2 Parentheses Parentheses are tedious for us to handle. We can introduce some rule to reduce the number of parentheses without ambiguity. 1. The outermost parenthesis need not be explicitly mentioned. 2. The negation symbol applies to as little as possible. 3. The conjuction and disjunction symbols apply to as little as possible. 4

4. Where one connective symbols is used repeatedly, grouping is to the right All these explicit rules make our parsing algorithm complicated if you want to accommodate the right proposition other than well-defined ones for convenience. Furthermore, you should prove that explicit rule would not result in ambiguity 4. 3 Polish notation Rules are not convenient. However there is a smart way to get rid of parentheses permanently, it is just the Polish notation. As we have already known, any connective is just a function with one or two parameters. We can represent a proposition as following without any parentheses 2. D(a, B)=VaB 3.DA(a,B)=∧aB 4.D→(a,B)=→aB 5.D4(a,B)=+aB It is called Polish notation. Actually, it can be expanded to any n-ary function Consider the following example, which is translated from a well-defined proposition Example 4. Determine the well defined proposition of →∧AD∨→BCB It is easy to recover the well-defined form. Do it as an exercise Yah! We do eliminate parentheses successfully. But what is your feeling about Polish notation when you try to figure out what it represents. In fact, it is an approach very suitable for machine but human. To us, the well-defined way is much better There are several approached to translate Polish representation into regular one, which is left as 5 Appendix: Inductive definition In our class, many definitions are defined recursively or inductively. We just introduce Definition 6. A set s is closed under a single operation f(s1, .. Sn)if and only if every s1,..., Sn E n)∈S Definition 7. The clo of a set S under(all) the operations in a set t is the smallest C such

4. Where one connective symbols is used repeatedly, grouping is to the right. All these explicit rules make our parsing algorithm complicated if you want to accommodate the right proposition other than well-defined ones for convenience. Furthermore, you should prove that explicit rule would not result in ambiguity. 4.3 Polish notation Rules are not convenient. However there is a smart way to get rid of parentheses permanently, it is just the Polish notation. As we have already known, any connective is just a function with one or two parameters. We can represent a proposition as following without any parentheses: 1. D¬(α) = ¬α. 2. D∨(α, β) = ∨αβ. 3. D∧(α, β) = ∧αβ. 4. D→(α, β) =→ αβ. 5. D↔(α, β) =↔ αβ. It is called Polish notation. Actually, it can be expanded to any n-ary function. Consider the following example, which is translated from a well-defined proposition. Example 4. Determine the well defined proposition of → ∧AD ∨ ¬B ↔ CB. It is easy to recover the well-defined form. Do it as an exercise. Yah! We do eliminate parentheses successfully. But what is your feeling about Polish notation when you try to figure out what it represents. In fact, it is an approach very suitable for machine but human. To us, the well-defined way is much better. There are several approached to translate Polish representation into regular one, which is left as an exercise. 5 Appendix: Inductive definition In our class, many definitions are defined recursively or inductively. We just introduce Definition 6. A set S is closed under a single operation f(s1, . . . , sn) if and only if every s1, . . . , sn ∈ S, f(s1, . . . , sn) ∈ S Definition 7. The closure of a set S under (all) the operations in a set T is the smallest C such that 5

1. SECand 2.if∈Tisn- ary and s1,…,sn∈C, then f(81,…,sn)∈C ith these concepts, we have an Theorem on the property of inductive definition Theorem 8. Suppose that s is closed under the operations of T, there is a smallest closure C such chat scc Proof. Given a set D, sCD and D is closed under the operations of T. Consider the set C=nDISCDAD is closed under the operations of Th It is obvious that S CC. And C is the smallest set according to definition of C As a direct application of Theorem 8, we have the following Theorem about well-defined Definition Theorem 9. Ifs is a set of well defined propositions and is closed under all five connectives, then s is the set of all well defined propositions Exercises 1. Show that there are no well-defined propositions of length 2, 3, or 6, but that any other positive length is possible 2. Given an example such that(aAB)=(rns)but afr, where a and B are well-defined and r and d are two expressions. 3. Draw formation tree of the following propositions (a)(AVB)→(C)∧D) (b)((A)VB)∧(A(B)) 4. Let a be a well-defined proposition; let c be the number of places at which binary connective symbols(A,V,t, +)occur in a; let s be the number of places at which proposition letters occur in a. Show by using the induction principle that s=c+l 5. Determine the Polish notation of proposition or vice versa (a)(AVB)→(=C)∧D) (b)(A)B)∧(A(=B) (c)→∧-AB分C=D 6. Design a algorithm which can translate Polish notation of proposition into well defined propo- sition without stack or with at most one 7. Design a algorithm to translate a well-defined proposition into a Polish notation form

1. S ⊆ C and 2. if f ∈ T is n-ary and s1, . . . , sn ∈ C, then f(s1, . . . , sn) ∈ C. With these concepts, we have an Theorem on the property of inductive definition. Theorem 8. Suppose that S is closed under the operations of T, there is a smallest closure C such that S ⊆ C. Proof. Given a set D, S ⊆ D and D is closed under the operations of T. Consider the set C = ∩{D|S ⊆ D ∧ D is closed under the operations of T}. It is obvious that S ⊆ C. And C is the smallest set according to definition of C. As a direct application of Theorem 8, we have the following Theorem about well-defined Definition: Theorem 9. If S is a set of well defined propositions and is closed under all five connectives, then S is the set of all well defined propositions Exercises 1. Show that there are no well-defined propositions of length 2, 3, or 6, but that any other positive length is possible. 2. Given an example such that (α ∧ β) = (γ ∧ δ) but α 6= γ, where α and β are well-defined and γ and δ are two expressions. 3. Draw formation tree of the following propositions: (a) ((A ∨ B) → ((¬C) ∧ D)). (b) (((¬A) ∨ B) ∧ (A ∨ (¬B))). 4. Let α be a well-defined proposition; let c be the number of places at which binary connective symbols(∧, ∨, →, ↔ ) occur in α; let s be the number of places at which proposition letters occur in α. Show by using the induction principle that s = c + 1. 5. Determine the Polish notation of proposition or vice versa. (a) ((A ∨ B) → ((¬C) ∧ D)). (b) (((¬A) ∨ B) ∧ (A ∨ (¬B))). (c) → ∧¬AB ↔ C¬D. 6. Design a algorithm which can translate Polish notation of proposition into well defined propo￾sition without stack or with at most one. 7. Design a algorithm to translate a well-defined proposition into a Polish notation form. 6

点击下载完整版文档(PDF)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
已到末页,全文结束
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有