GithubHelp home page GithubHelp logo

prolog-assignment's Introduction

Assignment 1 - Problem A: Problem Statement

  • Design and implement a Prolog program to verify whether primitive expressions in a language like C are type-correct. For instance, an expression of the form x + y is type-correct if x and y are both of type int or they are both of type float.
  • An expression of the form v = e is type-correct if the expression e evaluates to the same type as that of variable v. Assume that the primitive types available in the language (along with the corresponding operations) are:
  • int and float (+, -, *, /, %, <, <=, >, >=, ==, !=)
  • Comparators (<, <=, etc.) evaluate to Boolean.
  • Boolean (&&, ||, !)
  • bitset (&,|,~, >>, <<)
  • Shift operators >> and << require bitset on the left and a positive int on the right.
  • address (&, +, -, *)
  • &v for any variable v returns a value of type address
  • e1 + e2 is type-correct if e1 is of type address and e2 is of type int; the result is of type address
  • e1 - e2 is type-correct if e1 and e2 are both of type address; the result is of type int
  • *e is type-correct if e is of type address; the result depends on the form of e: if e is a variable, then the result is of the same type as that of the variable; otherwise it is undefined Assume that variables can be of any type, and assignment operations include =, as well as any of the operators list above followed by = (for instance, &=, +=, >>=).
  • Assume TRUE and FALSE are constant values of type Boolean with the usual meanings. Assume that int and float values can be treated as bitset values in the contexts where operations require them.
  • Also include the ?: operator for verification of typecorrectness: ** i.e. expressions of the form e1 ? e2 : e3 ** where e1 must evaluate to Boolean, e2 and e3 must evaluate to the same type whatever that my be.

prolog-assignment's People

Contributors

daiviknema avatar deepvyas avatar smitpatwa avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.