-
Notifications
You must be signed in to change notification settings - Fork 0
/
3SAT_framework.hpp
93 lines (51 loc) · 2.95 KB
/
3SAT_framework.hpp
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
// 3SAT_framework.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#ifndef __3SATFRAMEWORK_H__
#define __3SATFRAMEWORK_H__
struct nlist { /* table entry: */
struct nlist* next; /* next entry in chain */
char* name; /* defined name */
char* defn; /* replacement text */
};
// single bit
typedef struct {
int id;
} bit_3sat;
// integer with decimal
typedef struct {
bit_3sat ** bits; // bit string
int sz; // size in bits of number
int bd_sz; // before decimal size
int ad_sz; // after decimal size
} dec_3sat;
bit_3sat* create_bit(int* num_parm);
dec_3sat* create_dec(int* num_parm, int bd_sz_parm, int ad_sz_parm);
char* and_3sat(int* num_parm, bit_3sat** c, bit_3sat* a, bit_3sat* b, int * len_para);
char* nand_3sat(int* num_parm, bit_3sat** c, bit_3sat* a, bit_3sat* b, int* len_para);
char* or_3sat(int* num_parm, bit_3sat** c, bit_3sat* a, bit_3sat* b, int* len_para);
char* nor_3sat(int* num_parm, bit_3sat** c, bit_3sat* a, bit_3sat* b, int* len_para);
char* not_3sat(int* num_parm, bit_3sat** c, bit_3sat* a, int* len_para);
char* xor_3sat(int* num_parm, bit_3sat** c, bit_3sat* a, bit_3sat* b, int* len_para);
char* xnor_3sat(int* num_parm, bit_3sat** c, bit_3sat* a, bit_3sat* b, int* len_para);
char* bitaddsum_3sat(int* num_parm, bit_3sat** sum, bit_3sat* c_in, bit_3sat* a, bit_3sat* b, int* len_para);
char* bitaddcout_3sat(int* num_parm, bit_3sat** c_out, bit_3sat* c_in, bit_3sat* a, bit_3sat* b, int* len_para);
char* implies_3sat(int* num_parm, bit_3sat** c, bit_3sat* a, bit_3sat* b, int* len_para);
char* dec_add(int* num_parm, dec_3sat** c, dec_3sat* a, dec_3sat* b, bool discard_final_c_out, int* len_para);
char* twos_comp_3sat(int* num_parm, dec_3sat** c, dec_3sat* a, int* len_para);
char* dec_sub(int* num_parm, dec_3sat** c, dec_3sat* a, dec_3sat* b, int* len_para);
char* equals(int* num_parm, dec_3sat* a, dec_3sat* b, bool eq, __int64* len_para);
char* not_equals(int* num_parm, dec_3sat* a, dec_3sat* b, __int64* len_para);
char* dec_mul(int * num_parm, dec_3sat** c, dec_3sat* a, dec_3sat* b, int bd_sz, int ad_sz, __int64* len_para);
char* dec_div(int * num_parm, dec_3sat * c, dec_3sat * a, dec_3sat ** b, __int64* len_para);
char* dec_sqrt(int* num_parm, dec_3sat* c, dec_3sat** a, __int64* len_para);
//void bignum_from_str_oct(bn* c_bn, char* c_str, int len);
inline int octal_from_char(char c);
//void bignum_from_str_oct(bn* c_bn, char* c_str, int len);
inline int decimal_from_char(char c);
inline int int_from_hex_char(char c);
inline char hex_char_from_int(int a);
//void bignum_from_str_dec(bn* c_bn, char* c_str, int len);
int** input_from_char_buf(char* buf_3sat, __int64 buf_3sat_sz, int* k, bool cnf);
char* dec_to_str(bool* decodable_buf, dec_3sat* a, int* str_sz);
char* get_factors(char* c_str, int c_str_buf_sz, int * len_para);
#endif // !__3SATFRAMEWORK_H__