File size: 2,672 Bytes
224e773
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
/*

 * nand.h — NAND Filter interface

 * Stage 8: Functionally complete Boolean logic via NAND primitive

 *

 * NAND is the universal Boolean gate: all other operators can be built from it.

 * By using NAND for all expert conflict resolution, we minimize the trusted base.

 *

 * NAND truth table:

 *   NAND(0, 0) = 1

 *   NAND(0, 1) = 1

 *   NAND(1, 0) = 1

 *   NAND(1, 1) = 0

 *

 * Derivations:

 *   NOT(a) = NAND(a, a)

 *   AND(a, b) = NAND(NAND(a, b), NAND(a, b))

 *   OR(a, b) = NAND(NOT(a), NOT(b))

 *   XOR(a, b) = NAND(AND(a, NOT(b)), AND(NOT(a), b))

 */

#pragma once
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/**

 * hk_nand_filter — Resolve conflicts between active experts

 *

 * For each pair of simultaneously-active experts:

 *   - If they conflict, suppress the lower-weight one

 *   - Use NAND logic to determine suppression

 *

 * @param active_experts  Bitmask of active expert indices (bit i = expert i)

 * @return Filtered bitmask (some experts may be suppressed)

 */
uint32_t hk_nand_filter(uint32_t active_experts);

/**

 * hk_nand_filter_cascading — Iteratively apply NAND filter until stable

 *

 * Applies hk_nand_filter repeatedly until the result converges

 * (i.e., no more experts are suppressed).

 *

 * @param active_experts  Initial active expert bitmask

 * @return Final (stable) expert bitmask

 */
uint32_t hk_nand_filter_cascading(uint32_t active_experts);

/**

 * hk_nand_authority_check — Authority predicate using NAND

 *

 * Authority = capability ∧ trusted ∧ approval

 * Implemented entirely using NAND.

 *

 * @param capability   1 if agent has capability, 0 otherwise

 * @param trusted      1 if agent is trusted, 0 otherwise

 * @param approval     1 if action has been approved, 0 otherwise

 * @return Authority: 1 if all three conditions met, 0 otherwise

 */
int hk_nand_authority_check(int capability, int trusted, int approval);

/**

 * hk_nand_admissible — Admissibility predicate using NAND

 *

 * Admissible = proof ∧ entropy_ok ∧ ¬dangerous

 * Implemented entirely using NAND.

 *

 * @param has_proof    1 if proof certificate exists, 0 otherwise

 * @param entropy_ok   1 if entropy ≤ 0.20 nats, 0 otherwise

 * @param not_dangerous 1 if not a dangerous pattern, 0 otherwise

 * @return Admissibility: 1 if action can propagate, 0 if blocked

 */
int hk_nand_admissible(int has_proof, int entropy_ok, int not_dangerous);

/**

 * hk_nand_print_circuit — Debug output

 *

 * Prints truth tables for NOT, AND, OR, IMPLIES constructed from NAND.

 */
void hk_nand_print_circuit(void);

#ifdef __cplusplus
}
#endif