-
Notifications
You must be signed in to change notification settings - Fork 0
/
Delay.sh~
executable file
·133 lines (106 loc) · 2.18 KB
/
Delay.sh~
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/sh
#SBATCH --job-name="Delay"
#SBATCH --output="RESULTS/%j.Delay.%N.out"
#SBATCH --partition=compute
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --export=ALL
#SBATCH -t 47:59:59
Rows=$1
Cols=$2
FormulaName="Delay"
FILE="SMT/${FormulaName}_${Rows}x${Cols}.smt2"
#Declaring the Polarities (To be found by the solver)
PolarityDecs=""
for i in `seq 1 $Rows`;
do
for j in `seq 1 $Cols`;
do
PolarityDecs="$PolarityDecs
(declare-const M$i${j}P Bool)"
done
done
#Declaring the Subsets (To be found by the solver)
SubsetDecs=""
for i in `seq 1 $Rows`;
do
for j in `seq 1 $Cols`;
do
SubsetDecs="$SubsetDecs
(declare-const SubR${i}_C$j Bool)"
done
done
#Defining ColVal: A function that will return the value of a column at t+1 given the on/off states of the memristors on it
ColValDef="(define-fun ColVal("
for i in `seq 1 $Rows`;
do
ColValDef="$ColValDef(m${i}_ Bool)"
done
ColValDef="$ColValDef) Bool
(or "
for i in `seq 1 $Rows`;
do
ColValDef="$ColValDef m${i}_"
done
ColValDef="$ColValDef)
)"
MainRule="(assert (forall ("
for i in `seq 1 $Rows`;
do
MainRule="$MainRule(r$i Bool)"
for j in `seq 1 $Cols`;
do
MainRule="$MainRule"
#(m${i}_${j} Bool)"
done
done
MainRule="$MainRule)
(and"
#For each row, the previous value should equal the and of the corresponding column in the time frame after
for i in `seq 1 $Rows`;
do
MainRule="$MainRule
(= r$i
(and"
for j in `seq 1 $Cols`;
do
MainRule="$MainRule
(or (not SubR${i}_C$j) (ColVal "
for k in `seq 1 $Rows`;
do
MainRule="$MainRule(MemristorVal M${k}${j}P r$k)"
done
MainRule="$MainRule))"
done
MainRule="$MainRule
)
)"
done
MainRule="$MainRule
)
))"
GetValue="(get-value ("
for i in `seq 1 $Rows`;
do
for j in `seq 1 $Cols`;
do
GetValue="$GetValue M${i}${j}P SubR${i}_C${j}"
done
done
GetValue="$GetValue))"
/bin/cat <<EOM >$FILE
;(define-sort ColSubset () (_ BitVec $Cols) ) ; #Defining the Subset type
$PolarityDecs
$SubsetDecs
; #The value of a memristor in t+1
(define-fun MemristorVal((polarity Bool)(Vr Bool)) Bool
(= polarity Vr) ; #Positive polarity memristors turn on when row in true (i.e. Vt)
)
$ColValDef
$MainRule
(check-sat)
$GetValue
EOM
date
./z3 $FILE
date