3 Rem 3: Binary Vector Notation
Throughout this work, we abuse notation by identifying a subset of vertices, edges, or cycles with its characteristic binary vector over \(\mathbb {Z}_2 = \mathbb {F}_2\). For a set \(S\) of vertices/edges/cycles, the corresponding binary vector has a \(1\) in position \(i\) if and only if element \(i\) belongs to \(S\). Addition of binary vectors corresponds to symmetric difference of sets. This identification allows us to use linear algebra over \(\mathbb {Z}_2\) to reason about graph-theoretic properties.
3.1 Binary Vectors over \(\mathbb {Z}/2\mathbb {Z}\)
A binary vector over an index set \(\alpha \) is a function \(\alpha \to \mathbb {Z}/2\mathbb {Z}\). This is the type of characteristic vectors.
The zero vector is the binary vector that is \(0\) at every coordinate:
The all-ones vector is the binary vector that is \(1\) at every coordinate:
Addition of binary vectors \(v, w : \alpha \to \mathbb {Z}/2\mathbb {Z}\) is defined componentwise:
3.2 Characteristic Vector of a Set
The characteristic vector of a finset \(S \subseteq \alpha \) is the binary vector \(\chi _S : \alpha \to \mathbb {Z}/2\mathbb {Z}\) defined by
For a finset \(S \subseteq \alpha \) and an element \(i \in \alpha \),
We prove each direction separately. For the forward direction, assume \(\chi _S(i) = 1\). By definition of \(\chi _S\), we unfold the characteristic vector. We split on whether \(i \in S\): if \(i \in S\), we are done; if \(i \notin S\), then \(\chi _S(i) = 0\), contradicting \(\chi _S(i) = 1\) by simplification. For the reverse direction, assume \(i \in S\). Then by definition \(\chi _S(i) = 1\), and this follows by simplification using the membership hypothesis.
For a finset \(S \subseteq \alpha \) and an element \(i \in \alpha \),
We prove each direction separately. For the forward direction, assume \(\chi _S(i) = 0\). Unfolding the definition of the characteristic vector and splitting on membership: if \(i \in S\), then \(\chi _S(i) = 1\), contradicting \(\chi _S(i) = 0\) by simplification; if \(i \notin S\), we are done. For the reverse direction, assume \(i \notin S\). Then by definition \(\chi _S(i) = 0\), which follows by simplification.
3.3 Symmetric Difference and Vector Addition
For finsets \(S, T \subseteq \alpha \),
Addition of characteristic vectors corresponds to symmetric difference. This is the fundamental property that allows linear algebra over \(\mathbb {Z}/2\mathbb {Z}\) to encode set operations.
By extensionality, it suffices to show equality for an arbitrary element \(i\). We simplify the left-hand side using the pointwise addition definition and the characteristic vector definition, and the right-hand side using the membership condition for symmetric difference. We then perform a case split on whether \(i \in S\) and whether \(i \in T\):
If \(i \in S\) and \(i \in T\): the left-hand side is \(1 + 1 = 0\) in \(\mathbb {Z}/2\mathbb {Z}\), and the right-hand side is \(0\) since \(i \notin S \mathbin {\triangle } T\).
If \(i \in S\) and \(i \notin T\): both sides equal \(1\) by simplification.
If \(i \notin S\) and \(i \in T\): both sides equal \(1\) by simplification.
If \(i \notin S\) and \(i \notin T\): both sides equal \(0\) by simplification.
For finsets \(S, T \subseteq \alpha \),
This is the symmetric form of the previous theorem, obtained by applying symmetry to \(\chi _S + \chi _T = \chi _{S \mathbin {\triangle } T}\).
For a finset \(S \subseteq \alpha \),
Rewriting using the addition-symmetric difference correspondence, \(\chi _S + \chi _S = \chi _{S \mathbin {\triangle } S}\). Since \(S \mathbin {\triangle } S = \emptyset \), we have \(\chi _\emptyset = 0\).
In \(\mathbb {Z}/2\mathbb {Z}\), every element is its own additive inverse. For a finset \(S\),
By extensionality, it suffices to show \((-\chi _S)(i) = \chi _S(i)\) for each \(i\). We simplify the negation and unfold the characteristic vector definition, then split on whether \(i \in S\). In both cases (\(\chi _S(i) = 1\) or \(\chi _S(i) = 0\)), the result follows by computation (deciding) in \(\mathbb {Z}/2\mathbb {Z}\), since \(-1 = 1\) and \(-0 = 0\) in this ring.
3.4 Inverse Map: From Binary Vector to Finset
Given a binary vector \(v : \alpha \to \mathbb {Z}/2\mathbb {Z}\), we define the corresponding finset as the support of \(v\):
For any finset \(S \subseteq \alpha \),
By extensionality, \(i \in \mathrm{fromBinaryVector}(\chi _S)\) iff \(\chi _S(i) = 1\). By the characteristic vector membership characterization, this is equivalent to \(i \in S\). The result follows by simplification.
For any binary vector \(v : \alpha \to \mathbb {Z}/2\mathbb {Z}\),
By extensionality, it suffices to show equality at each coordinate \(i\). We unfold the definitions of the characteristic vector and \(\mathrm{fromBinaryVector}\). Since every element of \(\mathbb {Z}/2\mathbb {Z}\) is either \(0\) or \(1\), we decompose \(v(i)\) into these two cases. In each case, the result follows by simplification: if \(v(i) = 0\), then \(i \notin \mathrm{fromBinaryVector}(v)\), so \(\chi (i) = 0 = v(i)\); if \(v(i) = 1\), then \(i \in \mathrm{fromBinaryVector}(v)\), so \(\chi (i) = 1 = v(i)\).
The characteristic vector map \(\chi : \mathrm{Finset}(\alpha ) \to \mathrm{BinaryVector}(\alpha )\) is injective.
Let \(S, T\) be finsets with \(\chi _S = \chi _T\). By extensionality, we need to show \(i \in S \iff i \in T\) for all \(i\). Using the membership characterization, \(i \in S \iff \chi _S(i) = 1 \iff \chi _T(i) = 1 \iff i \in T\), where the middle equivalence follows from \(\chi _S = \chi _T\).
The characteristic vector map \(\chi : \mathrm{Finset}(\alpha ) \to \mathrm{BinaryVector}(\alpha )\) is surjective.
Given a binary vector \(v\), take \(S = \mathrm{fromBinaryVector}(v)\). Then \(\chi _S = v\) by the round-trip property, which follows by simplification.
The characteristic vector map \(\chi : \mathrm{Finset}(\alpha ) \to \mathrm{BinaryVector}(\alpha )\) is a bijection.
This follows directly from injectivity and surjectivity of the characteristic vector map.
The characteristic vector map as a type equivalence \(\mathrm{Finset}(\alpha ) \simeq \mathrm{BinaryVector}(\alpha )\), with forward map \(\chi \) and inverse map \(\mathrm{fromBinaryVector}\). Theleft and right inverses are given by the two round-trip properties.
3.5 Algebraic Structure: Finsets as a Vector Space over \(\mathbb {Z}/2\mathbb {Z}\)
Addition on \(\mathrm{Finset}(\alpha )\) is defined via symmetric difference:
The type \(\mathrm{Finset}(\alpha )\) forms an additive commutative group with symmetric difference as addition, \(\emptyset \) as the zero element, and identity as negation (since every element is its own inverse in \(\mathbb {Z}/2\mathbb {Z}\)). The group axioms hold because:
Associativity: \((S \mathbin {\triangle } T) \mathbin {\triangle } U = S \mathbin {\triangle } (T \mathbin {\triangle } U)\).
Identity: \(\emptyset \mathbin {\triangle } S = S\) and \(S \mathbin {\triangle } \emptyset = S\).
Inverse: \(S \mathbin {\triangle } S = \emptyset \).
Commutativity: \(S \mathbin {\triangle } T = T \mathbin {\triangle } S\).
Scalar multiplication by \(\mathbb {Z}/2\mathbb {Z}\) on \(\mathrm{Finset}(\alpha )\) is defined as:
The type \(\mathrm{Finset}(\alpha )\) forms a module (vector space) over \(\mathbb {Z}/2\mathbb {Z}\), where addition is symmetric difference and scalar multiplication is as defined above. The module axioms are verified by case analysis on elements of \(\mathbb {Z}/2\mathbb {Z}\) (which are either \(0\) or \(1\)).
For finsets \(S, T \subseteq \alpha \) (where addition on finsets is symmetric difference),
We unfold the definition of addition on finsets (which is symmetric difference), and the result follows directly from the symmetric difference correspondence theorem.
For \(c \in \mathbb {Z}/2\mathbb {Z}\) and a finset \(S \subseteq \alpha \),
We decompose \(c\) into the cases \(c = 0\) and \(c = 1\) (the only elements of \(\mathbb {Z}/2\mathbb {Z}\)).
Case \(c = 0\): We substitute \(c = 0\). The left-hand side becomes \(\chi _{0 \cdot S} = \chi _\emptyset = 0\). For the right-hand side, by extensionality at each coordinate \(i\), we simplify \(0 \cdot \chi _S(i)\) using the zero scalar action and verify it equals \(0\) by the symmetry of \(0 \cdot x = 0\).
Case \(c = 1\): We substitute \(c = 1\). The left-hand side becomes \(\chi _{1 \cdot S} = \chi _S\). For the right-hand side, by extensionality at each coordinate \(i\), we use \(1 \cdot \chi _S(i) = \chi _S(i)\) by the symmetry of \(1 \cdot x = x\).
The characteristic vector map is a linear equivalence
with forward map \(\chi = \mathrm{characteristicVector}\), inverse map \(\mathrm{fromBinaryVector}\), additivity \(\chi (S + T) = \chi (S) + \chi (T)\), and scalar compatibility \(\chi (c \cdot S) = c \cdot \chi (S)\).
3.6 Properties for Graph Theory Applications
For disjoint finsets \(S, T \subseteq \alpha \) (i.e., \(S \cap T = \emptyset \)),
Rewriting using the addition-symmetric difference correspondence, it suffices to show \(S \cup T = S \mathbin {\triangle } T\). Since \(S\) and \(T\) are disjoint, the symmetric difference equals the union, which follows from the lemma that disjoint symmetric difference equals the supremum (union).
For finsets \(S, T \subseteq \alpha \) and any \(i \in \alpha \),
Let \(i\) be arbitrary. We unfold the definition of the characteristic vector using the membership condition for intersections. We perform a case split on whether \(i \in S\) and whether \(i \in T\):
If \(i \in S\) and \(i \in T\): both sides equal \(1 \cdot 1 = 1\).
If \(i \in S\) and \(i \notin T\): both sides equal \(1 \cdot 0 = 0\).
If \(i \notin S\) and \(i \in T\): both sides equal \(0 \cdot 1 = 0\).
If \(i \notin S\) and \(i \notin T\): both sides equal \(0 \cdot 0 = 0\).
All cases follow by simplification.
For a finset \(S \subseteq \alpha \),
where \(\mathbf{1}\) denotes the all-ones vector and \(S^c\) is the complement of \(S\) relative to the universe.
By extensionality, it suffices to verify at each coordinate \(i\). We unfold the definitions of \(\mathbf{1}\), pointwise addition, and the characteristic vector, using the membership condition for complements. We split on whether \(i \in S^c\): if \(i \notin S\) then \(\chi _{S^c}(i) = 1\) and \(1 + 0 = 1\); if \(i \in S\) then \(\chi _{S^c}(i) = 0\) and \(1 + 1 = 0\) in \(\mathbb {Z}/2\mathbb {Z}\). Both cases are verified by computation.
The cardinality of a finset \(S\) can be recovered from its characteristic vector:
where \(\mathrm{val} : \mathbb {Z}/2\mathbb {Z} \to \mathbb {N}\) is the distance-minimal representative.
We split the sum over the universe into a sum over elements in \(S\) and a sum over elements not in \(S\): \(\sum _{i \in \alpha } \mathrm{val}(\chi _S(i)) = \sum _{i \in S} \mathrm{val}(\chi _S(i)) + \sum _{i \notin S} \mathrm{val}(\chi _S(i))\). We first observe that \(\{ i \in \alpha \mid i \in S\} = S\) by extensionality and simplification. For the first sum: for each \(i \in S\), \(\chi _S(i) = 1\), so \(\mathrm{val}(\chi _S(i)) = 1\), hence \(\sum _{i \in S} 1 = |S|\) (rewriting the cardinality as a sum of ones). For the second sum: for each \(i \notin S\), \(\chi _S(i) = 0\), so \(\mathrm{val}(\chi _S(i)) = 0\), hence the sum is \(0\). Combining by integer arithmetic (omega), \(|S| = |S| + 0\).
Two finsets are equal if and only if their characteristic vectors are equal:
The forward direction follows by rewriting: if \(S = T\) then \(\chi _S = \chi _T\). The reverse direction follows from injectivity of the characteristic vector map: if \(\chi _S = \chi _T\) then \(S = T\).
For finsets \(S, T \subseteq \alpha \),
We use the standard cardinality identity \(|S \cup T| + |S \cap T| = |S| + |T|\) (Finset.card_union_add_card_inter). We then establish that \(S \mathbin {\triangle } T = (S \cup T) \setminus (S \cap T)\) by extensionality: \(x \in S \mathbin {\triangle } T\) iff \(x \in (S \cup T) \setminus (S \cap T)\), which follows by unfolding the definitions and applying propositional logic (tauto). Since \(S \cap T \subseteq S \cup T\) (by Finset.inter_subset_union), we apply the cardinality of set difference for subsets: \(|S \mathbin {\triangle } T| = |S \cup T| - |S \cap T|\). We also have \(|S \cap T| \le |S \cup T|\) (by monotonicity of cardinality). The desired identity \(|S \mathbin {\triangle } T| + 2|S \cap T| = |S| + |T|\) then follows by integer arithmetic (omega) from these three facts.