/* Simple linear congruential random number generator with the following parameters X(n+1) = (a*X(n) + b) mod m where a = 11 b = 23 mod = 127 X(1) = 1 The first entries: 1 34 16 72 53 98 85 69 20 116 29 88 It has a cycle of 125. Can we restore the parameters? Well, it's very easy when using the specific constants: [1,11,23,127] maxCount = 3 code = (((A * 11) + 23) mod 127) = [[[1],34],[[34],16],[[16],72],[[72],53]] = [[53] = 98] but it's too hard when using e.g. 0..10 or 1..127 With tabling get_op/5 it yields an "out_of_memory" error after 11 minutes during maxCount = 3. (My Picat run is restricted to 32Gb RAM on a 64Gb RAM machine.) Now testing Constaints 0..127 without tabling: Nope. Stopped after 19 hours without any solution. */ data(linear_congruential_generator,Data,Vars,Unknown,Ops,Constants,MaxC) :- make_seq([1,34,16,72,53,98,85,69,20,116,29,88],1,Data,Unknown,Vars), % make_seq([1,34,16,72,53],1,Data,Unknown,Vars), println(data=Data), % Ops = new_map([infix=["+","-","*","/","mod"]]), Ops = new_map([infix=["+","*","mod"]]), % We know that it's an LCG. Constants = [1,11,23,127], % OK, but cheating :-) % Constants = 0..10, % Too hard % Constants = 0..127, % Too hard MaxC = 5.