Building a 4×4 Chinese Idiom Word Square with Constraint Solving

    A 4×4 idiom word square requires every row and every column to read as a valid four-character Chinese idiom or fixed phrase. This article clarifies the problem definition, introduces a tiered standard for judging candidates, models the construction task as a constraint satisfaction problem with prefix indexing and backtracking, and outlines practical engineering steps for dictionary preparation, validation, and iterative refinement.

    When discussing whether a “4×4 idiom word square” can be constructed, the first step is to define the problem precisely. The “order-4 square” here is not a numerical matrix from linear algebra with determinants and invertibility, but a 4×4 arrangement of Chinese characters: each row, read left to right, must be a four-character idiom or fixed phrase, and each column, read top to bottom, must satisfy the same requirement. If only the four rows need to hold, the problem is relatively easy; requiring all four rows and four columns simultaneously turns it into a combinatorial search problem under dictionary constraints.

    The core question, therefore, is not “can we write four idioms in a row,” but “does a 4×4 character matrix exist whose row vectors and column vectors all fall within the same or a tier-defined dictionary set.” Without specifying the dictionary scope, the criteria for phrase admission, and the reading direction, “whether it can be constructed” has no absolute answer. Strictly speaking, one should first define a dictionary D, then determine whether a matrix M exists such that all four row vectors and four column vectors of M belong to D. If free-form phrases are allowed into the judgment, almost any column reading can be interpreted as some kind of phrase, and the evaluation loses its constraining power.

    Tiered Acceptance Criteria: Idioms, Fixed Phrases, and Free Phrases Must Not Be Mixed

    Consider this candidate matrix:

    人 财 两 空
    身 经 百 战
    一 专 多 能
    行 家 里 手

    The four rows read as “人财两空” (ren cai liang kong), “身经百战” (shen jing bai zhan), “一专多能” (yi zhuan duo neng), and “行家里手” (hang jia li shou) — all valid idioms, so the row direction reads well overall. But reading the columns gives “人身一行”, “财经专里”, “两百多手”, and “空战能手”. “空战能手” can be understood as a modifier-noun phrase, but it is not a typical idiom; “人身一行”, “财经专里”, and “两百多手” are hard to classify as established fixed phrases. This candidate is therefore at best “an idiom matrix in the row direction with a few approximate column phrases,” not a strict order-4 idiom word square.

    It is useful to define several acceptance levels:

    1. L0: All four rows are idioms or fixed phrases; no requirement on columns. This level is the easiest — AI coding assistants or manual arrangement can produce candidates quickly.
    2. L1: All four rows are idioms, and all four columns are acceptable four-character fixed phrases, though columns need not be idioms. This level requires a phrase whitelist; otherwise the boundary of “phrase” is too loose.
    3. L2: All four rows and four columns are idioms or dictionary-recognized fixed expressions. This is a strict idiom word square.
    4. L3: Building on L2, add quality requirements such as semantic thematic coherence, avoidance of rare characters, and a lower rate of repeated characters.

    The original candidate sits roughly at L0, and approaches L1 on the fourth column, but does not reach L2. Interpreting “everything else is fine” as “the row direction is fine” is reasonable; interpreting it as “the 4×4 square holds” is not. Formal validation must be performed row by row and column by column — a readable row direction alone is not sufficient grounds for a conclusion.

    Strict Construction: Modeling the Problem as a CSP

    Let D be the set of four-character idioms and permitted fixed phrases, and let M be a 4×4 character array where M[r][c] is the character at row r and column c. A strict square requires:

    • For each r, M[r][0..3] ∈ D;
    • For each c, M[0..3][c] ∈ D.

    This is a finite-domain constraint satisfaction problem (CSP). The variables can be viewed as the choices of the four row words; each row choice contributes one character to each of the four columns. The columns are not independent variables — they are consequences of the row selections. During the search, therefore, you should not pick four arbitrary rows and then check the columns; instead, maintain each column’s prefix as rows are placed and prune promptly.

    A direct but inefficient approach enumerates all combinations of four rows from D and then checks the columns. With a dictionary of size N, naive enumeration reaches N^4, and most combinations fail early. A better approach is to build a prefix index: for every word in the dictionary, collect all prefixes of length 1 to 3 into a set P. After placing row r, check whether the prefix formed so far in each column is in P; if any column’s prefix is not in P, no completion can ever become a dictionary word, so backtrack immediately. After placing the fourth row, verify that each column’s complete string is in D.

    Illustrative pseudocode:

    1. D = load_four_character_dictionary_and_phrase_whitelist()
    2. P = build_prefix_sets_of_length_1_to_3(D)
    3. M = empty 4x4 matrix
    4. function column_prefix_feasible(r):
    5. for c from 0 to 3:
    6. p = concat(M[0..r][c])
    7. if r < 3 and p not in P: return False
    8. if r == 3 and p not in D: return False
    9. return True
    10. function search(r):
    11. if r == 4: return True
    12. for w in D:
    13. M[r] = w
    14. if column_prefix_feasible(r) and search(r + 1):
    15. return True
    16. M[r] = empty
    17. return False

    This framework exhaustively finds strict solutions under the given dictionary. If the search returns True, you have a formally valid candidate; if exhaustive search returns False, the problem is infeasible under the current dictionary and reading-direction definition. Note that “infeasible” holds only for the given dictionary — it cannot be extrapolated to claim such a square is absolutely impossible in the Chinese language.

    Search Optimization: Prefix Indexing, Candidate Ordering, and Symmetry

    Although a 4×4 matrix is small, the dictionary can be large, so optimization is still needed. First, group the dictionary by first character or prefix to avoid scanning all entries every time. Second, apply a “minimum remaining candidates first” heuristic: for each row position, estimate how many words remain available given the current column prefix constraints, and fill the row with the fewest candidates first. Third, maintain a candidate set per column: once a column’s prefix is fixed, restrict its candidates to words with that prefix, shrinking the search space for subsequent rows.

    Symmetry also matters. The transpose of a strict square is still a strict square, because the row and column conditions are symmetric — if M is valid, so is Mᵀ. However, permuting rows or columns usually destroys the existing row and column words and cannot be treated as an equivalent transformation. The reading direction must be agreed on in advance: by default, left to right and top to bottom; allowing right-to-left or bottom-to-top readings enlarges the acceptance set and changes the nature of the problem. Even with relaxed column requirements, the original candidate fails when read backwards, so relaxing direction does not rescue its strictness.

    Candidate Evaluation: Formal Validation First, Semantic Quality Second

    Candidate matrices should be evaluated in two layers. The first layer is formal validation: check every row and column against the dictionary and report hits. The second layer is a quality score covering row hit rate, column hit rate, acceptability of column fixed phrases, proportion of rare characters, proportion of repeated characters, and semantic thematic coherence. A score can be defined as:

    score = w1 × row_idiom_count + w2 × column_idiom_count + w3 × column_fixed_phrase_count − w4 × rare_character_degree − w5 × semantic_conflict_degree

    In strict mode, the terms corresponding to w1 and w2 must all be satisfied, or the candidate is rejected outright. In relaxed mode, the score can be used to search for “approximate solutions.” The original candidate has four solid rows and a readable fourth column “空战能手”, but its first three columns fail the fixed-phrase requirement, so it is suitable as a relaxed-mode candidate rather than the final answer in strict mode.

    Engineering Practice: Dictionaries, Validation, and Iteration

    In practice, start with a small dictionary of high-frequency idioms to validate the workflow, then expand gradually. The dictionary needs normalized characters, handling of variant and polyphonic characters, and an explicit decision on whether fixed expressions like “一专多能” are admitted into the idiom set. The phrase whitelist must be maintained manually — free-form phrases should not be admitted without limit. After generating candidates, validate every row and column programmatically, then review semantics and readability by hand. AI coding assistants can help generate candidates, propose arrangements, or write validation scripts, but the final judgment should rely on a well-defined dictionary and a reproducible search process — not on a subjective impression that something “looks good.”

    The conclusion: a 4×4 idiom word square can be constructed, but only after defining the dictionary boundary of “idiom/phrase” and the tiered row-column constraints. When only four rows are required, the original candidate is already good; when all four rows and four columns must hold strictly, it falls short. Transforming the problem into a constraint search with prefix indexing and backtracking pruning, combined with tiered evaluation and manual validation, is what makes feasibility judgments reliable and enables steady improvement of candidate quality.