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

  • Home
  • SEARCH
  • 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 6892393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:31:46+00:00 2026-05-27T06:31:46+00:00

I’m learning sml and trying to make a program that simplifies logic formulas. When

  • 0

I’m learning sml and trying to make a program that simplifies logic formulas. When I try to run this code, I always get the same error, which I cannot figure out. It’s always “Error: syntax error: deleting BAR ID DARROW”. I’ve attached the code below:

- fun Simplify (Or(True, _)) = True
= | Simplify (Or(_, True)) = True
= | Simplify (Or(False, False)) = False
= | Simplify (Or(x, False)) = (Simplify x)
= | Simplify (Or(False, x)) = (Simplify x)
= | Simplify (Or (Var (x), Var (y))) = Or (Var (x), Var (y))
= | Simplify (Or (x, y)) = case Simplify x of
=                                       True => True
=                                       | False => Simplify y
=                                       | x' => case Simplify
=                                       | True => True
GC #0.0.0.0.2.85:   (2 ms)
=                                       | False => x'
stdIn:50.6-50.15 Error: syntax error: deleting  BAR ID DARROW
-                                       | y' => Or(x', y')
= (*And*)
= | Simplify (And(_, False)) = False
stdIn:2.1-2.8 Error: syntax error: deleting  BAR ID DARROW
stdIn:54.1-54.11 Error: syntax error: deleting  BAR ID
- | Simplify (And(False, _)) = False
stdIn:1.1-2.6 Error: syntax error: deleting  BAR ID
- | Simplify (And(True, True)) = True
= | Simplify (And(True, x)) = (Simplify x)
stdIn:1.1-2.6 Error: syntax error: deleting  BAR ID
- | Simplify (And(x, True)) = (Simplify x)
= | Simplify (And(Var (x), Var(y))) = And (Var (x), Var (y))
stdIn:1.1-2.6 Error: syntax error: deleting  BAR ID
- | Simplify (And (x, y)) = case Simplify x of
stdIn:1.1-2.6 Error: syntax error: deleting  BAR ID
stdIn:53.3-57.4 Error: syntax error: deleting  CASE ID
-                               False => False
=                               | True => Simplify y
stdIn:2.6-62.6 Error: syntax error: deleting  DARROW ID BAR
-                               | x' => case Simplify y of
=                               | False => False
stdIn:1.5-2.7 Error: syntax error: deleting  BAR ID DARROW
-                               | True => x'
=                               | y' => And(x', y')
stdIn:1.5-2.9 Error: syntax error: deleting  BAR ID DARROW
- (*Not*)
- | Simplify (Not(Not(x))) = (Simplify x)
= | Simplify (Not(True)) = False
stdIn:68.1-68.11 Error: syntax error: deleting  BAR ID
- | Simplify (Not(False)) = True
= | Simplify (Not(Var (x))) = (Not (Var x))
stdIn:1.1-68.3 Error: syntax error: deleting  BAR ID
GC #0.0.0.0.3.201:   (1 ms)
- | Simplify (Not x) = case Simplify x of
stdIn:1.1-68.3 Error: syntax error: deleting  BAR ID
stdIn:68.14-71.4 Error: syntax error: deleting  CASE ID
-                                True => False
=                               | False => True
stdIn:68.3-74.6 Error: syntax error: deleting  DARROW ID BAR
-                               | x' => Not x'
= (*general*)
= | Simplify True = True
stdIn:1.5-68.4 Error: syntax error: deleting  BAR ID DARROW
- | Simplify False = False
= | Simplify (Var(x)) = Var(x);

I’ve added the whole code:

datatype formula =
True
| False
| Var of string 
| Not of formula
| And of formula * formula
| Or of formula * formula;

fun Simplify (Or(True, _)) = True
| Simplify (Or(_, True)) = True
| Simplify (Or(False, False)) = False
| Simplify (Or(x, False)) = (Simplify x)
| Simplify (Or(False, x)) = (Simplify x)
| Simplify (Or (Var (x), Var (y))) = Or (Var (x), Var (y))
| Simplify (Or (x, y)) = case Simplify x of
                    True => True
                    | False => Simplify y
                    | x' => case Simplify y of
                    | True => True
                    | False => x'
                    | y' => Or(x', y')
(*And*)
| Simplify (And(_, False)) = False
| Simplify (And(False, _)) = False
| Simplify (And(True, True)) = True
| Simplify (And(True, x)) = (Simplify x)
| Simplify (And(x, True)) = (Simplify x)
| Simplify (And(Var (x), Var(y))) = And (Var (x), Var (y))
| Simplify (And (x, y)) = case Simplify x of
                False => False
                | True => Simplify y
                | x' => case Simplify y of
                | False => False
                | True => x'
                | y' => And(x', y')
(*Not*)
| Simplify (Not(Not(x))) = (Simplify x)
| Simplify (Not(True)) = False
| Simplify (Not(False)) = True
| Simplify (Not(Var (x))) = (Not (Var x))
| Simplify (Not x) = case Simplify x of
                 True => False
                | False => True
                | x' => Not x'
(*general*)
| Simplify True = True
| Simplify False = False
| Simplify (Var(x)) = Var(x);
  • 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-27T06:31:47+00:00Added an answer on May 27, 2026 at 6:31 am

    You need to have parenthesis around nested case statements, also when using them and having multiple function clauses, as it is not possible to differentiate the pipe (|) from belonging to the fun clauses or the case clauses.

    Also you are missing the “y” argument to simplify in the second case of Simplify (Or (x, y)), and some of your nested case expressions have a starting pipe, where it shouldn’t:

    fun Simplify (Or (True, _)) = True
      | Simplify (Or (_, True)) = True
      | Simplify (Or (False, False)) = False
      | Simplify (Or (x, False)) = Simplify x
      | Simplify (Or (False, x)) = Simplify x
      | Simplify (Or (Var x, Var y)) = Or (Var x, Var y)
      | Simplify (Or (x, y)) = (case Simplify x of
                                  True => True
                                | False => Simplify y
                                | x' => (case Simplify y of
                                           True => True
                                         | False => x'
                                         | y' => Or(x', y')))
      (*And*)
      | Simplify (And (_, False)) = False
      | Simplify (And (False, _)) = False
      | Simplify (And (True, True)) = True
      | Simplify (And (True, x)) = (Simplify x)
      | Simplify (And (x, True)) = (Simplify x)
      | Simplify (And (Var x, Var y)) = And (Var x, Var y)
      | Simplify (And (x, y)) = (case Simplify x of
                                   False => False
                                 | True => Simplify y
                                 | x' => (case Simplify y of
                                            False => False
                                          | True => x'
                                          | y' => And(x', y')))
      (*Not*)
      | Simplify (Not (Not x)) = (Simplify x)
      | Simplify (Not True) = False
      | Simplify (Not False) = True
      | Simplify (Not (Var x)) = Not (Var x)
      | Simplify (Not x) = (case Simplify x of
                              True => False
                            | False => True
                            | x' => Not x')
      (*general*)
      | Simplify True = True
      | Simplify False = False
      | Simplify (Var x) = Var x
    

    Atleast this compiles with this rather wrongish datatype:

    datatype Expr = Or  of Expr *  Expr
                  | And of Expr * Expr
                  | Not of Expr
                  | Var of Expr
                  | True
                  | False
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

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.