In MiniZinc, you can't use "if condition then ... else ... endif" when the condition involves decision variables. Instead reifications must then be used and they are stated using "->", "<-" and "<->":
c1 -> c2 implication
c2 <- c1 implication (same as c1 -> c2)
c1 <-> c2 equivalence
So, the two constraints should be written like this (assuming that "r1" and "r4" are decision variables):
constraint
(r1 != r4 <-> b14=1)
/\
(r1 != r4 -> cost[r1,r4] = 1)
;
Always put parenthesis around the reifications when working with more than one constraints in a "constraint" section, otherwise the parser may interpret the constraints the wrong way.
Also, note that an element in a matrix are written as
cost[r1,r2]
That said, if you can use if/then/else/endif construct, then you probably should do that since translating a reification is normally more costly.