Download
language Essence 1.3

given nbDom : int(1..)
letting dom be domain int(1..nbDom)
given bound : int(1..100)
letting Postion be domain (int(1..bound),int(1..bound))

given numClues : int(1..bound**2)
letting Clue be domain int(1..numClues)
letting Arg be domain int(1..numClues)

letting Type be new type enum  {Add, Modulo}
$ locations
given l : function (total,injective) Clue  --> (Type, Arg, Arg, Postion  ) 


find grid : matrix indexed by [int(1..bound),int(1..bound)] of dom


such that

forAll i : Clue .  (
    l(i)[1] = Add ->
    grid[ l(i)[4,1], l(i)[4,2] ] =  
        grid[ l( l(i)[2] )[4,1]  , l( l(i)[2] )[4,2]  ] 
      + grid[ l( l(i)[3] )[4,1]  , l( l(i)[3] )[4,2]  ] ) /\ (

    l(i)[1] = Modulo -> 
    grid[ l(i)[4,1], l(i)[4,2] ] =  
        grid[ l( l(i)[2] )[4,1]  , l( l(i)[2] )[4,2]  ] 
      % grid[ l( l(i)[3] )[4,1]  , l( l(i)[3] )[4,2]  ] 
)