← All courses

23 lessons · about 71 minutes of video

Correspondence Matrices: From Logic to Code

Build, transform and verify Boolean rules with correspondence matrices, then use them in Python. Follow the course in order or return to a particular construction.

Start with basic Boolean values and operators. The final five lessons use Python and a checkout of the CM_Computation repository; the earlier lessons can be followed on paper.

1. Foundations and layouts

Turn a truth table into a labelled matrix, build larger rules, and change their layout.

  1. From truth tables to operator CMsRead a CM in numeric and bracketed-operator notation.3:49
  2. Build CMs from four basis matricesBuild a numeric basis matrix and connect it to its operator symbol.2:29
  3. Calculate a CM measurementCompute both groupings of ⟨0|[⇕]|1⟩ using AND and XOR.3:39
  4. Derive the paper’s implication exampleDerive the page-7 identity, including intermediate rows and simplification.3:42
  5. Expressions first, values secondEvaluate an expression-valued LM and distinguish it from a numeric CM.3:05
  6. Two logical matrices become a 4×4Expand a tensor product and identify its full row and column components.2:58
  7. Build and check a four-variable ruleConstruct the paper example and verify a cell directly from its Boolean rule.3:30
  8. Find a cell in the repository layoutSplit an assignment, convert binary groups to indices, and check the stored output.3:09
  9. Change the layout, keep the functionTrack one assignment through 4×4, 2×8, and 8×2 layouts.3:13

Try the paper checkpoint →

2. Matrix operations

Transpose, negate, compose and factor; connect numeric and formula-valued matrices.

  1. Swap operands by transposing a CMExplain a transpose with its operand order and labelled axes.2:41
  2. Negate an input, or negate the outputDistinguish entry complement from row and column permutations.2:42
  3. Compose and decompose over XORUse XOR composition with aligned matrices and explicit overlap checks.2:51
  4. Remove shared features with a CM quotientCompute a quotient as entrywise A∧¬B and preserve its order.2:27
  5. Combine rules with a shared ordered basisNormalize order and negations, then compose and verify the result.2:36
  6. Complement and factor logical matricesKeep symbolic factors, entrywise operations and valuation separate.3:02
  7. Measure with a logical matrixCompute the intermediate vectors; distinguish matched constants from general formulas.2:54
  8. Generalize the tensor constructionGeneralize tensors by tracking factors, axis order and assignment count.3:00
  9. Transform and combine larger CMsAlign axes, apply the outer rule entrywise, and verify all assignments.2:44

3. From mathematics to code

Use the public Python API, verify a complete example, and compare output contracts fairly.

  1. Explicit CM versus the repository’s CM-IRName the representation and output contract before discussing its behavior.2:46
  2. Build, query and validate a CM in codeBuild through the public API and validate against a separate scalar oracle.3:15
  3. Packed evaluation, execution choices and output costDistinguish representation, execution strategy and unavoidable output work.3:48
  4. When preparation pays: a fair comparisonEvaluate preparation tradeoffs with declared costs and matching output contracts.2:39
  5. A small end-to-end access-policy exampleBuild a bounded CM application with explicit inputs, outputs and exhaustive verification.3:35

Try the programming checkpoint →

Practice and reference