-
Notifications
You must be signed in to change notification settings - Fork 0
/
sugar.py
83 lines (75 loc) · 2.67 KB
/
sugar.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from pyclid import UclidContext, UclidBooleanType, UclidIntegerType, PortType, UclidOpExpr, UclidCheckCommand, UclidPrintResultsCommand
# Variable creation sugaring
def mkUclidVar(varname, typ, porttype):
UclidContext.curr_module.mkVar(varname, typ, porttype)
def mkUclidVars(varnames : list, typ, porttype):
return [UclidContext.curr_module.mkVar(varname, typ, porttype) for varname in varnames]
def mkUclidIntVar(varname : str, porttype=PortType.var):
return UclidContext.curr_module.mkIntegerVar(varname, porttype)
def mkUclidIntVars(varnames : list, porttype=PortType.var):
return [UclidContext.curr_module.mkIntegerVar(varname, porttype) for varname in varnames]
def mkUclidBoolVar(varname : str, porttype=PortType.var):
return UclidContext.curr_module.mkBooleanVar(varname, porttype)
def mkUclidBoolVars(varnames : list, porttype=PortType.var):
return [UclidContext.curr_module.mkBooleanVar(varname, porttype) for varname in varnames]
def mkUclidBVVar(varname : str, width : int, porttype=PortType.var):
return UclidContext.curr_module.mkBVVar(varname, width, porttype)
# Expression sugaring
def Uadd(args):
return UclidOpExpr("add", args)
def Usub(args):
return UclidOpExpr("sub", args)
def Uumin(args):
return UclidOpExpr("umin", args)
def Ugt(args):
return UclidOpExpr("gt", args)
def Ugte(args):
return UclidOpExpr("gte", args)
def Ult(args):
return UclidOpExpr("lt", args)
def Ulte(args):
return UclidOpExpr("lte", args)
def Ueq(args):
return UclidOpExpr("eq", args)
def Uneq(args):
return UclidOpExpr("neq", args)
def Unot(args):
return UclidOpExpr("not", args)
def Uxor(args):
return UclidOpExpr("xor", args)
def Uand(args):
return UclidOpExpr("and", args)
def Uor(args):
return UclidOpExpr("or", args)
def Uimplies(args):
return UclidOpExpr("implies", args)
def Ubvadd(args):
return UclidOpExpr("bvadd", args)
def Ubvsub(args):
return UclidOpExpr("bvsub", args)
def Ubvand(args):
return UclidOpExpr("bvand", args)
def Ubvor(args):
return UclidOpExpr("bvor", args)
def Ubvnot(args):
return UclidOpExpr("bvnot", args)
def Ubvlt(args):
return UclidOpExpr("bvlt", args)
def Ubvult(args):
return UclidOpExpr("bvult", args)
def Ubvgt(args):
return UclidOpExpr("bvgt", args)
def Ubvugt(args):
return UclidOpExpr("bvugt", args)
def Unext(args):
return UclidOpExpr("next", args)
def Ueventually(args):
return UclidOpExpr("eventually", args)
def Ualways(args):
return UclidOpExpr("always", args)
def Uconcat(args):
return UclidOpExpr("concat", args)
UBool = UclidBooleanType()
UInt = UclidIntegerType()
CMD_check = UclidCheckCommand()
CMD_print = UclidPrintResultsCommand()