I'm trying to solve Sudoku using linear programming. In Sudoku, it is known that each row and column of the grid must contain number from 1 to 9 without duplicates. I need a constraint function that enforces this rule.

Given a set of natural numbers: $a\_1, a\_2, a\_3$. I need a linear function $f$ (ie.
$f(a\_1, a\_2, a\_3) = c\_1 a\_1 + c\_2 a\_2 + c\_3 a\_3$) to check whether the set is contains each number starting from 1 in order once. For example, the linear function will return some value $x$ for the following permutations

$f(1,2,3) = x$

$f(2,1,3) = x$

$f(3,1,2) = x$

$f(1,3,2) = x$

$f(2,3,1) = x$

$f(3,2,1) = x$

But will return different value for the other permutations like

$f(1,2,5) ≠ x$

$f(2,2,2) ≠ x$

$f(3,1,-1) ≠ x$

$f(10, 2,-6) ≠ x$

$f(3, 4, 5) ≠ x$

I'm thinking about $f(a\_1, a\_2, a\_3)=a\_1+a\_2+a\_3$ which will return 6 for any permutation of $1,2,3$. But this function will also return the same result $2,2,2$ which is not what I want. Does the better linear function exist?

If the linear function does not exist then what is the nonlinear function for this problem?