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 8558933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:55:27+00:00 2026-06-11T15:55:27+00:00

I am using pattern matching on argument passed to a function. The method works

  • 0

I am using pattern matching on argument passed to a function. The method works fine for “first level” matching so to say but any attempt to go deeper gives the error “stdIn:282.5-291.77 Error: match redundant“

example

fun nnf T = T
    | nnf F = F
    | nnf (LETTER(x)) = (LETTER(x))
    | nnf (NEG(x)) = (NEG(nnf x))
    | nnf (AND(x,y)) = (AND(nnf x, nnf y))
    | nnf (OR(x,y)) = (OR(nnf x, nnf y))
    | nnf (IMP(x,y)) = (OR(NEG(nnf x),(nnf y)))
    | nnf (NEG(NEG(LETTER(x)))) = (LETTER(x))
    | nnf (NEG(AND(LETTER(x),LETTER(y)))) = (OR(NEG(LETTER(x)),NEG(LETTER(y))))
    | nnf (NEG(OR(LETTER(x),LETTER(y)))) = (AND(NEG(LETTER(x)),NEG(LETTER(y))));
val nnf = fn : prop -> prop

the error i get is

stdIn:282.5-291.77 Error: match redundant
          T => ...
          F => ...
          LETTER x => ...
          NEG x => ...
          AND (x,y) => ...
          OR (x,y) => ...
          IMP (x,y) => ...
    -->   NEG (NEG (LETTER x)) => ...
    -->   NEG (AND (LETTER x,LETTER y)) => ...
    -->   NEG (OR (LETTER x,LETTER y)) => ...

so SML is saying that the last 3 clauses in the function definition are the same since they all begin with “(NEG(…” even though what follows is different.

how do i overcome this ?

  • 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-06-11T15:55:28+00:00Added an answer on June 11, 2026 at 3:55 pm

    The case NEG(x) already covers any possible case involving outermost NEG, so the others are never reached. Depending on what you actually want to achieve, either remove that case, or move it after the more specific ones (cases are tried in order).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Duplicate of: There is a function to use pattern matching (using regular expressions) in
I am using this pattern and matching a string. String s = //name:value /name:value;
I'm encountering a situation where I'm using pattern matching for determining the visibility property
I my application I am using below regex for pattern matching. Original Pattern :
This page has a great example using REGEXP to do pattern matching. The problem
Is it possible to match on a comparison using the pattern matching system in
What are the performance benefits of using ~ (lazy pattern matching) in Data.List's partition.
I'm using vim to do some pattern matching on a text file. I've enabled
In Java, when we try to do pattern matching using a regular expression. e.g.
i need to find few words or matching pattern using a Javascript. this is

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.