Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3940992
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:29:13+00:00 2026-05-20T00:29:13+00:00

Ok so I divided my huge problem set into small parts, and I’m trying

  • 0

Ok so I divided my huge problem set into small parts, and I’m trying to do them one at a time.

I’m writting a function that will remove tautologies from a formula.The basic idea is that if in a clause, a literal and its negation are found, it means that the clause will be true, regardless of the value finally assigned to that propositional variable.My appoach is to create a function that will remove this but for a clause and map it to the formula. Of course, I have to remove duplicates at the beginning.

module Algorithm where

import System.Random
import Data.Maybe
import Data.List

type Atom = String
type Literal = (Bool,Atom)
type Clause = [Literal]
type Formula = [Clause]
type Model = [(Atom, Bool)]
type Node = (Formula, ([Atom], Model))
removeTautologies :: Formula -> Formula
removeTautologies = map tC.map head.group.sort
  where rt ((vx, x) : (vy, y) : clauses) | x == y = rt rest
                                      | otherwise = (vx, x) : rt ((vy, y) : clauses)

Now I have problems when I try to give it a formula (for example (A v B v -A) ^ (B v C v A)).Considering that example the first clause contains the literals A and -A. This means that the clause will always be true, in which case it can be simplify the whole set to simply (B v C v A) . But I get the following

Loading package old-locale-1.0.0.2 ... linking ... done.
Loading package time-1.1.4 ... linking ... done.
Loading package random-1.0.0.2 ... linking ... done.
[[(True,"A"),(True,"B")*** Exception: Algorithm.hs:(165,11)-(166,83): Non-exhaustive patterns in function rt

What should I do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T00:29:14+00:00Added an answer on May 20, 2026 at 12:29 am

    Think about what happens when you pass [(True,"A"),(True,"B"),(False,"A")] to the rt function:

    rt [(True,"A"),(True,"B"),(False,"A")] =
      = rt ((True,"A"):(True,"B"):[(False,"A")] =
        -- (vx,x) = (True,"A"), (vy,y) = (True,"B"), clauses = [(False, "A")]
      = (True, "A") : rt ((True,"B"):[(False, "A")] =
        -- (vx,x) = (True,"B"), (vy,y) = (False,"A"), clauses = []
      = (True, "A") : (True,"B") : rt (False, "A"):[] =
        -- (vx,x) = (True,"B"), (vy,y) = ???
    

    In your recursive invocations you are gradually passing shorter and shorter lists to rt. But you don’t have an equation to deal with lists with less than one element!

    You need to had such an equation. Think about what should rt [(False, "A")] return. I think the correct answer would be to simply return [(False, "A")] unchanged:

    rt [(vx,x)] = [(vx,x)]
    

    Now, are you considering the possibility of having empty formulas?
    “Nah, an empty formula makes no sense!”

    Well, think about the formula (A ∨ ¬A). It is a tautology. If you remove it you’re left with an empty formula! So, an empty formula does make some sense. It is the most basic tautology.

    What happens if we pass an empty formula to rt? Again, there is no equation for rt []. In this case, you cannot remove anything else. You’ll have to return it untouched, just like before:

    rt [] = []
    

    If you want you can combine these two extra equations into a single one:

    rt ((vx, x) : (vy, y) : clauses) | -- ... blah blah
                                     | -- ... blah blah
    rt x = x
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a huge matrix that I divided it into some sub matrices and
I have a project divided into several sub-modules (each of them are jar libraries):
Windows XP start menu is divided into two parts, the left and the right.
I have a memory block that is divided into a series of location that
My questions are divided into three parts Question 1 Consider the below code, #include
I have my system divided into 2 parts. Both parts communicate with each other
I am trying to plot a ratio but my problem is that when the
I divided my problem into a short and a long version for the people
I'm building a Seam application, which is basically a huge form divided into different
My application is logically divided into server, which contain my Grails domain objects and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.