- 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 Introduction
prolog-assignment's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.