Knowee
Questions
Features
Study Tools

Now that you have finished these two tasks, you have a working resolution algorithm and you can use the unsatisfiable function to test the satisfiability of your formulas.However, often we would like to use the resolution technique to prove not just the satisfiability or unsatisfiability of a single propositional formula, but logical consequence relationships between two propositional formulas.Your final task for this section of the worksheet is to implement an additional function inside Main.hs to do just that. This function should be pretty simple, and should make use of the existing unsatisfiable function. For this to work, you'll need to copy over your solutions from the previous problems once again.Write a function entails which takes two Formulas f and g and returns True if and only if formula g is a logical consequence of f (in which case, we would say that f entails g). Don't forget a type signature!For example:Main> entails [[Pos 'Q', Neg 'P'], [Pos 'P']] [[Pos 'Q']]TrueMain> entails [[Pos 'Q', Neg 'P']] [[Pos 'P', Neg 'Q']]False

Question

Now that you have finished these two tasks, you have a working resolution algorithm and you can use the unsatisfiable function to test the satisfiability of your formulas.However, often we would like to use the resolution technique to prove not just the satisfiability or unsatisfiability of a single propositional formula, but logical consequence relationships between two propositional formulas.Your final task for this section of the worksheet is to implement an additional function inside Main.hs to do just that. This function should be pretty simple, and should make use of the existing unsatisfiable function. For this to work, you'll need to copy over your solutions from the previous problems once again.Write a function entails which takes two Formulas f and g and returns True if and only if formula g is a logical consequence of f (in which case, we would say that f entails g). Don't forget a type signature!For example:Main> entails [[Pos 'Q', Neg 'P'], [Pos 'P']] [[Pos 'Q']]TrueMain> entails [[Pos 'Q', Neg 'P']] [[Pos 'P', Neg 'Q']]False

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

To implement the entails function, you can follow these steps:

  1. Define the function entails that takes two formulas f and g as input and returns True if and only if formula g is a logical consequence of f.
entails :: Formula -> Formula -> Bool
entails f g = undefined
  1. To check if g is a logical consequence of f, you can use the unsatisfiable function on the formula f and the negation of g. If the result is True, then g is a logical consequence of f.
entails f g = unsatisfiable (f ++ map negateFormula g)

Here, negateFormula is a function that negates a formula (e.g., it returns Neg 'A' for Pos 'A' and vice versa).

Here's the complete code:

import Data.List

type Literal = Char
type Clause = [Literal]
type Formula = [Clause]

complementaryLiteral :: Literal -> Literal
complementaryLiteral lit = if lit == 'Pos' then 'Neg' else 'Pos'

negateFormula :: Clause -> Clause
negateFormula = map complementaryLiteral

unsatisfiable :: Formula -> Bool
unsatisfiable f = not (null latest)
  where
    f' = reduce (remove_tautologies (map reduce f))
    (older, latest) = until finished evolve ([], f')
    finished (old, young) = null young || [] `elem` young

entails :: Formula -> Formula -> Bool
entails f g = unsatisfiable (f ++ map negateFormula g)

You can now use the entails function to check if a formula g is a logical consequence of another formula f.

This problem has been solved

Similar Questions

Which are needed to compute the logical inference algorithm?ans.All of the mentionedLogical equivalenceValiditySatisfiability Previous Marked for Review Next

Construct a truth table for the formula .

2. Use a tree to test whether the following two propositions are equivalent. (Present the tree, and say whether they’re equivalent or not.) If they’re not equivalent, read off from your tree a model on which the propositions have different truth values (and indicate the path from which you are reading it off). ∀x(Ax → Gx) ∃x(Ax → Gx)

Exercise b) Recall that a formula ϕ is a tautology if and only if ¬ϕ is not satisfiable, cf. Exercise 1.2.61in Rosen that we have covered in class, that is, to check whether ϕ is a tautology, you can check whether¬ϕ is satisfiable, and reverse the answer. Note also, that since the tableau rules only deal with negation andconjunction, you have to rewrite ϕ such that it only contains these two connectives. Now, make tableaus, asthey are presented in Priest’s book, Section 1.4, showing that the formulas p → (p ∨ q) and ¬p → (p → q)are tautologies, cf. exercises 1.2.11b and 1.2.11c in Rosen’s book

A _________ is used to demonstrate, on a purely syntactic basis, that one formula is a logical consequence of another formula

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.