I built this formula in preparation for CS3243 finals, but on hindsight it was overkill and the exam didnβt even need thisβ¦ π’
But, in the spirit of sharing, hereβs my questionable formula and the method I obtained this.
General CNF at least k, n variables
For variables, . Arrange them into combinations of k variables.
Denote the set of k-variable combinations, , or more formally in the following footnote^1.
Each element in C is a k-combination of X in DNF, so:
- //note: a combination of k variables
Then, the CNF of βat least kβ is:
>
i.e.
>
Example: βat least 2, 4 variablesβ
We start with the βstandardβ formulation:
The CNF form has 4C3 = 4 clauses. Applying the general form formulaβ¦
βProofβ
We start with the βgeneral formβ for the βat least kβ constraint.
Letβs assume we have 3 variables.
> At least 1 ==
> At least 2 ==
See the pattern? At least 2, given 3 variables is the disjunction of combinations of 3 variables.
Ok. Thatβs a mouthful, but I hope you get it.
You can prove this pattern to yourself by using 4 variables, but I do not recommend that unless you like the tedium of enumerating combinations.
The issue now is the tedium of converting DNF to CNF.
Since we donβt have implications (->) and NOTs (!) to worry about, we can simply2 just distribute the terms and regroup them into CNF. See this stack exchange post for an example of distributing over many terms.
theWe can try and inductively (weak) figure out if there is a pattern.
We just need to do the βsimpleβ task of enumerating ALL the CNFs from their standard form and see if there is a patternβ¦
k | n | Standard form | CNF |
---|---|---|---|
2 | 3 | (Xββ§Xβ)β¨(Xββ§Xβ)β¨(Xββ§Xβ) | (Xββ¨Xβ)β§(Xββ¨Xβ)β§(Xββ¨Xβ) |
^ Now, do that for sequential k and n!
Tedium by Wolframalpha
So, like all good engineers, we turn to Wolframalpha to do the heavy lifting for computational work.
Surprisingly, wolfram allows natural language input for boolean expressions and automatically shows CNF and DNF forms for any given expression.

Neat!
After varying for multiple k and n, this is the pattern we seeβ¦
k | n | Standard form | CNF |
---|---|---|---|
2 | 2 | (xββ§xβ) | (xβ)β§(xβ) |
2 | 3 | (Xββ§Xβ)β¨(Xββ§Xβ)β¨(Xββ§Xβ) | (Xββ¨Xβ)β§(Xββ¨Xβ)β§(Xββ¨Xβ) |
2 | 4 | (xββ§xβ)β¨(xββ§xβ)β¨(xββ§xβ)β¨(xββ§xβ)β¨(xββ§xβ)β¨(xββ§xβ) | (xββ¨xββ¨xβ)β§(xββ¨xββ¨xβ)β§(xββ¨xββ¨xβ)β§(xββ¨xββ¨xβ) |
3 | 3 | (xββ§xββ§xβ) | (xββ§xββ§xβ) |
3 | 4 | (xββ§xββ§xβ)β¨(xββ§xββ§xβ)β¨(xββ§xββ§xβ)β¨(xββ§xββ§xβ) | (xββ¨xβ)β§(xββ¨xβ)β§(xββ¨xβ)β§(xββ¨xβ)β§(xββ¨xβ)β§(xββ¨xβ) |
As you can see, with higher k and n the number of clauses explodes, so the table omits3 certain values such as n > 4 and k > 3.
It should be somewhat obvious what the emerging pattern is.
Observe that for the standard form,
- Each conjunctive clause (e.g. (xββ§xβ) ) is joined via disjunction to another clause
- Each clause is a unique combination of
k
vars out ofn
- By extension, this means that the |clauses| =
For the CNF form,
- Each disjunctive clause (e.g. (Xββ¨Xβ)) is joined via conjunction to another clause
- Each clause is a unique combination if
n-k+1
vars4 out ofn
.- By extension, this means that |clauses| =
We can generalize this by defining a set of all unique combinations of clauses in disjunctive normal form and chaining them conjunctively.
This leads to the formula given aboveβ¦
Where is an element in the set of all unique combinations of clauses, ,
At least k
given n
variables is:
>
i.e.
>
Of course, this is a (pretty) weak induction. I am sure there is some way to hack out a formal proof using the law of distributivity and blah blahβ¦ but for what itβs worth, this is enough for most cases in CS3243 and perhaps small-bounded problems.
If I have more free time, perhaps I will try and hammer out a stronger induction case using a general case n
, but for now this suffices (for me) for day-to-day use.
So⦠QED?
-
One does not simply distribute terms. Good luck doing it by hand! β©οΈ
-
I also do not intend to type out the ridiculous number of clauses that are generated in latex. Itβs unreadable! If you arenβt convinced, the rows for n > 4 and k > 3 are left as an exercise to the reader π β©οΈ
-
The term
n-k+1
is not particularly obvious. But if you count the terms and cross-check with each row, it makes sense. β©οΈ