Free Variables in First-Order Logic: A well-formed formula (wff) in first-order logic is defined as follows: An atomic formula, p(a1,...,an), is a wff, where p is a predicate symbol (ID token) and a1,...,an (n > 0) are arguments that can be numbers (NUMBER token), or strings enclosed within single quotation marks (STRING token), or variables (ID token
Free Variables in First-Order Logic: A well-formed formula (wff) in first-order logic is defined as follows: An atomic formula, p(a1,...,an), is a wff, where p is a predicate symbol (ID token) and a1,...,an (n > 0) are arguments that can be numbers (NUMBER token), or strings enclosed within single quotation marks (STRING token), or variables (ID token
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 17RQ
Related questions
Question
- Free Variables in First-Order Logic: A well-formed formula (wff) in first-order logic is defined as follows:
- An atomic formula, p(a1,...,an), is a wff, where p is a predicate symbol (ID token) and a1,...,an (n > 0) are arguments that can be numbers (NUMBER token), or strings enclosed within single quotation marks (STRING token), or variables (ID token). We shall assume that the ID token begins with a lower-case letter and is followed zero or more letters or digits. Even though the variables are made up of lower and upper-case letters, these should be considered case-insensitive. For example, value1, vALUE1, vAlue1, etc all should be treated as the same variable. For simplicity, we may assume that the STRING tokens are made up of letters and digits.
- If F1 and F2 are wffs, then F1 and F2, F1 or F2, and not F1 are wffs. (Note that we do not enforce parentheses!)
- If F is a wff and x1,...,xn are variables (n > 0), then (exists x1,...,xn)(F), (forall x1,...,xn)(F), and (F) are wffs. (Note that here we enforce parentheses!)
Recall the definition of "free variables" in wffs from your Discrete Math (CSC 2510/MATH 2420) class.
Write a CFG for wffs as defined above. Make sure to enforce precedence rules and left associativity on the logical operators. Then, using PLY define the tokens in WFFLexer.py and the parser specfication in WFFParser.py. Using p[0] assignment statements construct an expression tree data structure similar to homework 1. Then, in the main program write a function, free_variables(tree), that computes the list of free variables in the expression denoted by tree. A sample run is shown below:
Mac-mini:wff raj$ python3 WFF.py WFF: p(x,20,'aa'); OPEN WFF with Free Variables: ['X'] WFF: (exists x,y)(p(x,u) and not q(y,v)); OPEN WFF with Free Variables: ['U', 'V'] WFF: (exists x,y)(p(x,y)); CLOSED WFF WFF: employee('John','B','Smith',t,u,v,w,x,y,z); OPEN WFF with Free Variables: ['T', 'U', 'V', 'W', 'X', 'Y', 'Z'] WFF: projects(h,20,'Stafford',k); OPEN WFF with Free Variables: ['H', 'K'] WFF: (exists t,w,x,y,z)( employee('John','B','Smith',t,u,v,w,x,y,z) ); OPEN WFF with Free Variables: ['U', 'V'] WFF: (exists r,t,u,v,w,x,y,z)( employee(q,r,s,t,u,v,w,x,y,z) and not ((exists m,n,o,p)(dependent(t,m,n,o,p)) ) ); OPEN WFF with Free Variables: ['Q', 'S'] WFF: exit; Note: A wff is OPEN if it contains a non-empty set of free variables and CLOSED otherwise.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT