BÀI TẬP LỚN MÔN CẤU TRÚC RỜI RẠC KÝ PHÁP BA LAN NGƯỢC CHO BIỂU THỨC LOGIC

14 5 0
BÀI TẬP LỚN MÔN CẤU TRÚC RỜI RẠC KÝ PHÁP BA LAN NGƯỢC CHO BIỂU THỨC LOGIC

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

TỔNG LIÊN ĐOÀN LAO ĐỘNG VIỆT NAM TRƯỜNG ĐẠI HỌC TÔN ĐỨC THẮNG KHOA CÔNG NGHỆ THÔNG TIN BÀI TẬP LỚN MÔN CẤU TRÚC RỜI RẠC KÝ PHÁP BA LAN NGƯỢC CHO BIỂU THỨC LOGIC Người hướng dẫn: GV NGUYỄN QUỐC BÌNH Người thực hiện: NGUYỄN VĂN LỘC – 518H0647 VÕ TUẤN LỘC – 518H0390 Lớp : 18H50302 Khoá : 22 THÀNH PHỐ HỒ CHÍ MINH, NĂM 2019 TỔNG LIÊN ĐỒN LAO ĐỘNG VIỆT NAM TRƯỜNG ĐẠI HỌC TƠN ĐỨC THẮNG KHOA CÔNG NGHỆ THÔNG TIN BÀI TẬP LỚN MÔN CẤU TRÚC RỜI RẠC REVERSE POLISH NOTATION FOR LOGIC EXPRESSION Người hướng dẫn: GV NGUYỄN QUỐC BÌNH Người thực hiện: NGUYỄN VĂN LỘC – 518H0647 VÕ TUẤN LỘC – 518H0390 Lớp : 18H50302 Khố : 22 THÀNH PHỐ HỒ CHÍ MINH, NĂM 2019 LỜI CẢM ƠN Thank you to the lecturer - Mr Nguyen Quoc Binh, for taking the time and effort to help and support us to complete this great exercise, he has answered and guided enthusiastically the necessary knowledge It is very useful and helpful to help this project complete as expected and bring value to Ton Duc Thang University with good projects And I also not forget to thank the contributions and companionship of my friend Vo Tuan Loc - Student of Information Technology, Computer Science Department for taking time and effort to support me to complete well and on time degree of this essay report Sincerely thank you 5 TÓM TẮT From a variety of sources and documents, this year's HKI (2019-2020) Discrete Structures exercise deals with the inverse Polish algorithm for logical expressions, from infix to postfix, postfix to truthtable The effect of this algorithm is that it will help the computer, calculate but the complex expression quickly The main function of the algorithm is to calculate the value of the expression, the focus and mainly we transfer the prime factor ( Infix) in suffix form (Postfix).We have been researching and learning about parallel Stack and List for the last time, and we also learn the logical operator functions used to convert Polish backwards and calculate and create a Truth Table based on the square That MỤC LỤC CHƯƠNG – GIỚI THIỆU ST T HỌ VÀ TÊN Nguyễn Văn Lộc Võ Tuấn Lộc MSSV LỚP CÔNG VIỆC 518H0647 18H5030 - Phân chia việc làm cụ thể thành viên -Tìm hiểu nghiên cứu phần”Infix to Postfix” 518H0390 18H0390 THỜI GIAN 27/10/2019 ĐỊA ĐIỂM Quán trà sữa nhà Văn Lộc 31/10/2019 -Viết báo cáo viết code 31/10/2019 -7/11/2019 -Tim hiểu nghiên cưu phần ’Postfix to Truthtable” -Viết code, fix bug làm báo cáo 27/10/2019 31/10/2019 31/10/2019 7/11/2019 Quán trà sữa nhà bạn Văn Lộc CHƯƠNG – CƠ SỠ LÝ THUYẾT 2.1 Reverse Polish Notation (RPN) - Reverse Polish Notation - Polish notation - It is a method of calculation proposed by the mathematician Jan Łukasiewicz around 1920 and it is a way of writing an algebraic expression which is very convenient for performing mathematical operations - Help the computer easily calculate the complex expressions that people need to handle quickly - Is the algorithm used to calculate the expression value, the focus is to bring the expression from the infix (infix) to the suffix form (postfix) - The basic feature of this writing is that there is no need to use brackets and always perform from left to right - A method to express expressions in which the operator notation is set after the arguments are run - Basically, the algorithm can be divided into the following two main stages: • Conversion: normal expression is converted into Polish Kpn form • Calculation: use the logical operator to calculate the expression value based on the Polish form of kpnđ - Logical state: Logically, an entity exists only in one of two states (True or False, or 1) - Logical variables: used specifically for states of entities A logical variable is represented by a symbol (word or sign) and it only accepts one of two values: or 2.2 The theory of basic logic and use to calculate truth values 2.2.1 Unary Operators Unary operators are the simplest operations because they can be applied to a single True or False value 2.2.2.Identity The identity is our trivial case It states that True is True and False is False 2.2.3 Negation 10 The negation operator is commonly represented by a tilde (~) or ¬ symbol It negates, or switches, something’s truth value We can show this relationship in a truth table A truth table is a way of organizing information to list out all possible scenarios We title the first column p for proposition In the second column we apply the operator to p, in this case it’s ~p (read: not p) So as you can see if our premise begins as True and we negate it, we obtain False, and vice versa Truth Table for Logical Negation in TF and 01 notations 2.2.4 Logical True and Logical False These are kinda strange operations Logical true always results in True and logical false always results in False no matter the premise These operations are often referred to as “always true” and “always false” 11 NOT NOT P ~P P ~P F T F T T F T F P Q P^Q Pv Q P Q P Q T T T T T T T F F T F F F T F T T F F F F F T T 12 CHƯƠNG –Thức nghiệm Our code works like this: First I wrote the PriorityOfOperator function to compare the order of operations In the Infix2Postfix function I will create a list and view it as a stack, perform a loop running on each element in Infix: -If the element is a letter, I will pass it into the Postfix string -If the element is in parentheses, then I will pass it on the stack -If the element is enclosed in parentheses, then I will pop the rest of the stack until it meets the opening parenthesis, stop by giving a while loop as long as the last element of the stack is not opening parenthesis -If the element is the operator, execute the while loop with the condition that the stack is not empty and the last element of the stack must not be parentheses, if the current operator is less than or equal to the operator at the end in the stack, pop the operator in the stack and pass it to Postfix then pass the current operator into the stack, otherwise only pass the current operator into the stack After performing the above loop, I write more loop to pop all the remaining elements in the stack Multifunctional Postfix2Truthtable singing, features you love our In Postfix2Truthtable, you can create a count list of Postfix, a list, a list Healthy and wonderful List Em 1 List is a list of him and he sang Postfix, resulting in an upgraded version and a stack Powerful number value and best value and list value (element) in list (element) in list (element) in list (element) in list of codes (charC, list (element)) The zip () function in Python answers and locks, is a tuple list iterator that combines elements and repetitive features Inside, focused, valuable, valuable, valuable, right, can be on the list The rest of me -If I'm a True / False value, overlap 13 -If integrated I am a name: + If I am a person not (), meanwhile, he, the other person, after he sings the result + In other cases, create two value variables that pop out from the stack, perform logical calculations based on the CalculatePostfix function and then pass that value back onto the stack and the result After performing the above two loops, I will add the result variable to the element at the index position of Truthtable TÀI LIỆU THAM KHẢO Tiếng Việt https://vi.wikipedia.org/wiki/Reverse_Polish_notation All the Lab on elit.tdt.edu.vn Tiếng Anh https://medium.com/i-math/intro-to-truth-tables-boolean-algebra-73b331dd9b94 ... Logical False These are kinda strange operations Logical true always results in True and logical false always results in False no matter the premise These operations are often referred to as “always... is a way of writing an algebraic expression which is very convenient for performing mathematical operations - Help the computer easily calculate the complex expressions that people need to handle... Nguyen Quoc Binh, for taking the time and effort to help and support us to complete this great exercise, he has answered and guided enthusiastically the necessary knowledge It is very useful and

Ngày đăng: 15/12/2022, 11:10

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan