module deschain_showcase. // Bounded, discrete presentation model. Coordinates are abstract grid units; // route projections are not physical motion or a robot safety certificate. pub input clock(tick:number). pub input hazard(active:bool). clock(0). hazard(false). fn wrap(?n:number,?size:number)->number = ?n % ?size. fn route_y(?lane:number,?x:number,?active:bool)->number = match ?active and ?lane<7 { true => match ?x>=32 and ?x<=108 { true => -12-?lane*4, false => 20+?lane*4 }, false => 20+?lane*4 }. pub relation agent(id:number,x:number,y:number,lane:number). agent(?lane*12+?slot,?x,route_y(?lane,?x,?active),?lane) if clock(?tick) and ?tick>=0 and ?tick<7200 and hazard(?active) and intrinsic range(0,11,?lane) and intrinsic range(0,11,?slot) and ?x=wrap(?tick+?slot*12,144). pub relation violation(id:number). violation(?id) if hazard(true) and agent(?id,?x,?y,_) and ?x>=48 and ?x<=92 and ?y>=18 and ?y<=46. pub relation collision(a:number,b:number). collision(?a,?b) if agent(?a,?x,?y,_) and agent(?b,?x,?y,_) and ?a=0 and ?tick<7200 and intrinsic range(0,15,?id). pub relation blocked(id:number,reason:text). blocked(?id,"kinematic_limit_04") if proposal(?id,_,_,?speed,_,_) and ?speed>6. blocked(?id,"clearance_02") if proposal(?id,_,_,_,?clearance,_) and ?clearance<8. pub relation eligible(id:number,utility:number). eligible(?id,?u) if proposal(?id,_,_,_,_,?u) and not blocked(?id,_). relation outranked(id:number). outranked(?id) if eligible(?id,?u) and eligible(_,?v) and ?v>?u. pub relation selected(id:number,x:number,y:number). selected(?id,?x,?y) if eligible(?id,_) and not outranked(?id) and proposal(?id,?x,?y,_,_,_). // All 24 orderings of four robots sharing one single-occupancy crossing. // Priority weights change with the recorded tick. Enumerating these finite // branches and their cost is law work, not a JavaScript search algorithm. relation robot(id:number). robot(0). robot(1). robot(2). robot(3). pub relation branch(id:number,a:number,b:number,c:number,d:number,cost:number). fn weight(?id:number,?tick:number)->number = 1+wrap(?id+?tick/30,4). branch(?a*64+?b*16+?c*4+?d,?a,?b,?c,?d, weight(?b,?tick)+2*weight(?c,?tick)+3*weight(?d,?tick)) if clock(?tick) and ?tick>=0 and ?tick<7200 and robot(?a) and robot(?b) and robot(?c) and robot(?d) and ?a!=?b and ?a!=?c and ?a!=?d and ?b!=?c and ?b!=?d and ?c!=?d. relation inferior(id:number). inferior(?id) if branch(?id,_,_,_,_,?cost) and branch(_,_,_,_,_,?lower) and ?lower