labs / lab-c-mathematics--logical-connectives
Next task →
Practical Labs/Lab: Logical connectives
Level 1 · mathematics

Lab: Logical connectives

Build a minimal, verifiable implementation that demonstrates Logical connectives. Connect the code to the governing equation, inspect its output numerically, and explain one failure case.

Mathematical basis

For Logical connectives, write the defining identity and prove the bound ∣f(x)−f(a)∣<ε|f(x)-f(a)|<\varepsilon whenever ∣x−a∣<δ|x-a|<\delta.

Instructions

  1. 01Read section 7 of the Logical connectives learning page and write its governing equation on paper.
  2. 02Implement the core operation in SymPy/NumPy on synthetic matrices and scalar functions. Do not call a library function that solves the whole task.
  3. 03Verify the implementation on a hand-computed three-element or 3×3 example before scaling up.
  4. 04Run the experiment with the tolerance ε and record maximum residual.
  5. 05Inspect the output, identify one discrepancy with the theory, and write a one-paragraph explanation.

Starter code

import numpy as np

def demonstrate(x, tol=1e-9):
    """Numerical check for Logical connectives."""
    x = np.asarray(x, float)
    assert x.size > 0
    return np.sum(x), np.max(np.abs(x))

s, m = demonstrate([1.0, 2.0, 3.0])
assert abs(s - 6.0) < 1e-12 and m == 3.0
print(s, m)