git.iko.soy/ikoHSE/SolveAvdoshin
on master help sign in
some work on class checking
commitdc097ecfd869121e2d27f424dc6ed60c9740ee14 authorIlya Gulkov <ifranked@gmail.com> dateThu 8 Oct 2015, 00:31 (11 years ago) parent91cb41e
1 file changed+87
SolveAvdoshin/BooleanFunctions.cs+87
SolveAvdoshin/BooleanFunctions.cs+87
@@ -135,6 +135,93 @@ namespace SolveAvdoshin
135135
136136 RepresentationPrinting.PrintTailor0EqOr(f);
137137 }
138+
139+ public static void PrintClosedClasses(int n)
140+ {
141+ BooleanFunction f = new BooleanFunction((byte)n);
142+
143+
144+ }
145+ }
146+
147+ static class ClosedClassChecking
148+ {
149+ public static bool CheckConservationZero(BooleanFunction f)
150+ {
151+ return ((f.Eval() >> 7) & 1) == 0;
152+ }
153+
154+ public static bool CheckConservationOne(BooleanFunction f)
155+ {
156+ return (f.Eval() & 1) == 1;
157+ }
158+
159+ public static bool CheckSelfDuality(BooleanFunction f)
160+ {
161+ bool res = true;
162+
163+ for(int i = 0; i < 8; i++) {
164+ if(((f.Eval() >> i) & 1) == ((f.Eval() >> (7 - i)) & 1)) {
165+ res = false;
166+ break;
167+ }
168+ }
169+
170+ return res;
171+ }
172+
173+ static bool AreAdjacent(int a, int b)
174+ {
175+ bool res = false;
176+
177+ for(int i = 0; i < 3; i++) {
178+ if(((a >> i) & 1) != ((b >> i) & 1)) {
179+ if(!res)
180+ res = true;
181+ else {
182+ res = false;
183+ break;
184+ }
185+ }
186+ }
187+
188+ return res;
189+ }
190+
191+ static bool IsGreatherThan(int a, int b)
192+ {
193+ int onesA = 0, onesB = 0;
194+
195+ for(int i = 0; i < 3; i++) {
196+ onesA += (a >> i) & 1;
197+ onesB += (b >> i) & 1;
198+ }
199+
200+ return onesA > onesB;
201+ }
202+
203+ public static bool CheckMonotony(BooleanFunction f)
204+ {
205+ bool res = true;
206+
207+ for(int i = 0; i < 8; i++) {
208+ for(int j = 0; j < 8; j++) {
209+ if(AreAdjacent(i, j) && IsGreatherThan(i, j)) {
210+ if(f.EvalAt(i) < f.EvalAt(j)) {
211+ res = false;
212+ break;
213+ }
214+ }
215+ }
216+ }
217+
218+ return res;
219+ }
220+
221+ public static bool CheckLinearity(BooleanFunction f)
222+ {
223+
224+ }
138225 }
139226
140227 static class DerivativePrinting