-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexpressions.py
52 lines (36 loc) · 1.07 KB
/
expressions.py
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
41
42
43
44
45
46
47
48
49
50
class Expression:
def to_variable(self):
return (name, item)
class IsType(Expression):
def __init__(self, ClassType, name):
self.var_name = name
self.var_value = ClassType(name)
def to_coq(self):
pass
def __repr__(self):
return "{} is a {}".format(self.var_name, self.var_value)
class IsGroupElement(Expression):
def __init__(self, elt, group):
self.elt = elt
self.group = group
def to_coq(self):
return "In U (S {}) {}".format(self.group.name, self.elt.name)
def __repr__(self):
return "{} ∈ {}".format(self.elt, self.group)
class IsEqual(Expression):
def __init__(self, left, right):
self.left = left
self.right = right
def to_coq(self):
return "{} = {}".format(self.left.to_coq(), self.right.to_coq())
def __repr__(self):
return "{} = {}".format(self.left, self.right)
class Product(Expression):
def __init__(self, a, b, operation="op G"):
self.operation = operation
self.a = a
self.b = b
def to_coq(self):
return "{} {} {}".format(self.operation, self.a, self.b)
def __repr__(self):
return "{} * {}".format(self.a, self.b)