The objective of this code is to determine if the hunter has a winning strategy in a game where a mole moves between four connected holes while the blind hunter attempts to shoot it. The game is modeled using sequences to represent the moves of both players, and logical predicates are used to identify valid moves and winning strategies. The goal is to define a “hunter word” that guarantees the hunter will win against any “mole word.”
here what i did:
# Declare the types of variables used in the program
ws1s; # We are working with the weak monadic second-order logic of one successor
# Declare variables
var2 ML, MB, HL, HB; # Second-order variables for mole and hunter positions (both big and low bits)
var1 len; # First-order variable for the length
# Predicate to determine if a move is valid
pred valid_move(ml_i, mb_i, ml_i_plus1, mb_i_plus1) =
(ml_i ~= ml_i_plus1) |
( (mb_i ~= mb_i_plus1) & ( ((ml_i = 0) & (ml_i_plus1 = 1)) | ((ml_i = 1) & (ml_i_plus1 = 0)) ) );
# Predicate to model the mole's moves
pred mole_word() =
all1 i: (i < len-1) => valid_move(ML(i), MB(i), ML(i+1), MB(i+1));
# Predicate to check if the hunter wins
pred play_won_by_hunter() =
ex1 i: (i < len) & (ML(i) = HL(i)) & (MB(i) = HB(i));
# Main formula to check if the hunter wins given valid mole moves
mole_word() & play_won_by_hunter();
i get this error :
MONA reply:
MONA v1.4-18 for WS1S/WS2S
Copyright (C) 1997-2016 Aarhus University
PARSING
Error in file '/tmp/tmp-mona-66-3734-191-572.mona' line 15 column 39
all1 i: (i < len-1) => valid_move(ML(i), MB(i), ML(i+1), MB(i+1));
^
'ML' used as a predicate or function
Execution aborted
Steven Essam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.