Implement a function called tautology? that takes as input a fully parenthesized formula and returns true if it is a tautology and false otherwise. As was the case in the previous lab, the formula will contain at least one set of parentheses for each operator, but may contain more. The best strategy for doing is to use an insight called Quine's method. It is based on the observation that if a formula, such as (p or (not p)), is a tautology, the result of substituting p with true is a tautology and the result of substituting p with false is also a tautology. This implies a computational strategy: to evaluate whether a formula F is a tautology 1. Collect all of the propositional variables. 2. Substitute every occurrence of the first variable with #t and every occurrence of the same variable with #f 3. Make two recursive calls to Tautology? “And” the results. 4. When all possible substitutions have been made, i.e., the formula contains only truth values, evaluate the formula and return the results. Racket code only please. No loops or hash, thank you
Implement a function called tautology? that takes as input a fully parenthesized formula and returns true if it is a tautology and false otherwise. As was the case in the previous lab, the formula will contain at least one set of parentheses for each operator, but may contain more.
The best strategy for doing is to use an insight called Quine's method. It is based on the observation that if a formula, such as (p or (not p)), is a tautology, the result of substituting p with true is a tautology and the result of substituting p with false is also a tautology. This implies a computational strategy: to evaluate whether a formula F is a tautology
1. Collect all of the propositional variables.
2. Substitute every occurrence of the first variable with #t and every occurrence of
the same variable with #f
3. Make two recursive calls to Tautology? “And” the results.
4. When all possible substitutions have been made, i.e., the formula contains only
truth values, evaluate the formula and return the results.
Racket code only please. No loops or hash, thank you
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images