Algebraic and Logic Expression Simplifier - Assignment #4 | CSCI 169, Assignments of Computer Science

Material Type: Assignment; Professor: Bellaachia; Class: Software Paradigms; Subject: Computer Science; University: George Washington University; Term: Fall 2007;

Typology: Assignments

Pre 2010

Uploaded on 08/18/2009

koofers-user-4xg
koofers-user-4xg 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
The George Washington University
School of Engineering and Applied Science
Department of Computer Science
CSci 169 – Software Paradigms – Fall 2007
Programming Assignment # 4: Algebraic & Logic Expression Simplifier
Due Date: Wednesday, December 10, 2007
Instructor: A. Bellaachia
Send the electronic version of your assignment to: [email protected]
Part I:
Consider the problem of simplifying an algebraic expression, such as the symbolic
differentiation. In this project, we would like to develop a
Logic Expression Simplifier
(LES) using the following simplification rules:
- Simplification using mathematical identities of false (0) and True (1) when added or
multiplied with another expression:
o C or False = C
o C or True = True
o C and False = False
o C and True = C
C can be either a constant or an unknown variable.
Write a scheme function that implements the above rules.
Notes:
o “And” and “Or” are reserved keywords
o Space is a delimiter.
o You assume that the expression is syntactically correct.
o You need to read a logical expression in infix format and apply your LES
o You can assume that the input expression is fully parenthesized
Examples:
- Input: False and True
- Output: False
- Input: (C and True) or (Y or False)
- Output: C or Y (It is ok if your input may look like (C) or (Y))
- Input: (C and False) or (Y or True)
- Output: True (It is ok if your input may look like (C) or (Y))
A. Bellaachia
pf2

Partial preview of the text

Download Algebraic and Logic Expression Simplifier - Assignment #4 | CSCI 169 and more Assignments Computer Science in PDF only on Docsity!

The George Washington University School of Engineering and Applied Science Department of Computer Science CSci 169 – Software Paradigms – Fall 2007 Programming Assignment # 4: Algebraic & Logic Expression Simplifier Due Date: Wednesday, December 10, 2007 Instructor: A. Bellaachia

Send the electronic version of your assignment to: [email protected]

Part I: Consider the problem of simplifying an algebraic expression, such as the symbolic

differentiation. In this project, we would like to develop a Logic Expression Simplifier

( LES ) using the following simplification rules:

  • Simplification using mathematical identities of false (0) and True (1) when added or multiplied with another expression: o C or False = C o C or True = True o C and False = False o C and True = C

C can be either a constant or an unknown variable.

Write a scheme function that implements the above rules.

Notes: o “And” and “Or” are reserved keywords o Space is a delimiter. o You assume that the expression is syntactically correct. o You need to read a logical expression in infix format and apply your LES o You can assume that the input expression is fully parenthesized

Examples:

  • Input: False and True
  • Output: False
  • Input: (C and True) or (Y or False)
  • Output: C or Y (It is ok if your input may look like (C) or (Y))
  • Input: (C and False) or (Y or True)
  • Output: True (It is ok if your input may look like (C) or (Y))

A. Bellaachia

Part II:

Consider the problem of simplifying an algebraic expression, such as the symbolic

differentiation. In this project, we would like to develop an Algebraic Expression Simplifier

( AES ) using the following simplification rules:

  • Simplification using mathematical identities of 0 and 1 when added or multiplied with another expression: o x + 0 = x o 2x * 1 = 2x o x * 0 = 0
  • Simplification based on adding and multiplying constants: o 5 + 4 = 9 o 2 * 3 = 6
  • Simplification based on adding unknown variables: o x + x = 2x o 3x + 4x = 7x

Write a scheme function that implements the above rules.

Part III:

Write a menu in Scheme that allows a user to enter an expression and choose a simplifier to simplify his/her the input expression.

A. Bellaachia