-
Notifications
You must be signed in to change notification settings - Fork 0
/
01Hw.scala
40 lines (33 loc) · 1.08 KB
/
01Hw.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
Homework 01
============
*/
object Hw01 {
/**
Consider the following language of propositional logic formulae:
*/
enum Exp:
case True() // constant true
case False() // constant false
case And(lhs: Exp, rhs: Exp)
case Or(lhs: Exp, rhs: Exp)
case Not(e: Exp)
import Exp._
/**
Tasks:
1) Implement the missing parts of the interpreter for these formulae
(the eval function).
Test the correctness by evaluating the example proposition given
below and add at least two more examples and test against these.
2) Add implication as a new kind of expression "Impl" and extend
the interpreter accordingly. Add at least two examples for testing.
*/
def eval(e: Exp) : Boolean = e match {
case True() => sys.error("not yet implemented")
case False() => sys.error("not yet implemented")
case And(l, r) => sys.error("not yet implemented")
case Or(l, r) => sys.error("not yet implemented")
case Not(e) => sys.error("not yet implemented")
}
val exampleProposition = And(Not(True()), False()) // should evaluate to false
}