WEBVTT

1
00:00:00.180 --> 00:00:04.580
How do we check a matrix built by code?

2
00:00:04.580 --> 00:00:10.304
We will construct a four-input rule through the repository public API, build its matrix,

3
00:00:10.304 --> 00:00:15.331
and test every assignment against an independent scalar calculation.

4
00:00:15.331 --> 00:00:20.765
Start with four indexed variables: A through D in our explanation,

5
00:00:20.765 --> 00:00:25.479
named x zero through x three in the repository.

6
00:00:25.479 --> 00:00:28.961
The accompanying Python example is runnable.

7
00:00:29.141 --> 00:00:36.095
Construct AND from A and B, OR from C and D, then place both under XOR.

8
00:00:36.095 --> 00:00:43.375
This object records the expression structure. It does
not rely on Python’s ordinary Boolean and operator,

9
00:00:43.375 --> 00:00:48.029
which would evaluate Python objects instead of building this expression tree.

10
00:00:48.209 --> 00:00:55.790
Choose x zero and x one as row variables, and x two and x three as column variables.

11
00:00:55.790 --> 00:00:59.923
The empty fixed dictionary means no input is held constant.

12
00:00:59.923 --> 00:01:06.526
With two free bits on each axis, the output has four rows and four columns.

13
00:01:06.706 --> 00:01:14.485
For A one, B one, C zero, D zero, pass every repository name in an assignment dictionary.

14
00:01:14.485 --> 00:01:22.240
Row bits one-one give index three and column bits zero-zero give index zero.

15
00:01:22.240 --> 00:01:28.846
Store the lookup result, then assert that it is one. This is runnable Python, not equation notation.

16
00:01:29.026 --> 00:01:32.416
Compute the expected answer directly from the four bits:

17
00:01:32.416 --> 00:01:38.059
A bitwise-AND B, exclusive-or C bitwise-OR D.

18
00:01:38.059 --> 00:01:43.991
Compare that with the lookup for every tuple from zero-zero-zero-zero to one-one-one-one.

19
00:01:43.991 --> 00:01:47.125
Sixteen checks cover the whole four-input function.

20
00:01:47.305 --> 00:01:52.460
Here are three representative balanced partitions: A B over C D,

21
00:01:52.460 --> 00:01:57.220
A C over B D, and A D over B C.

22
00:01:57.220 --> 00:02:01.864
We keep A in the row group and retain the original order within each list.

23
00:02:01.864 --> 00:02:06.461
Swapping axes or changing list order produces other valid layouts.

24
00:02:06.461 --> 00:02:11.721
The example checks these three representatives across all sixteen assignments.

25
00:02:11.901 --> 00:02:15.976
Import compilation and materialization from cm_ir.

26
00:02:15.976 --> 00:02:22.315
Compile the rule once, then materialize its node for each declared layout.

27
00:02:22.315 --> 00:02:25.624
Those arrays match direct public-wrapper construction.

28
00:02:25.624 --> 00:02:30.604
This distinguishes reusable preparation from the requested final matrix output.

29
00:02:30.784 --> 00:02:37.495
For A one, B zero, C one, D zero, use rows A C and columns B D.

30
00:02:37.495 --> 00:02:41.326
What row and column indices do you get, and what is the rule’s value?

31
00:02:41.326 --> 00:02:55.957
First split the bits according to the lists, then evaluate the scalar expression.

32
00:02:56.137 --> 00:03:03.068
The row bits A C are one-one, giving three. The column bits B D are zero-zero,

33
00:03:03.068 --> 00:03:09.175
giving zero. AND is zero, OR is one, so exclusive-or is one.

34
00:03:09.175 --> 00:03:15.073
This is a small reproducible correctness example; it does not make a performance claim.
