init {
	roads := {
		"static": {
			"road1": {
				"left": "road2"
			},
			"road2": {
				"right": "road1"
			}
		},
		"dynamic": {
			"road1": {
				"left": nil,
				"right": nil,
				"straight": nil
			},
			"road2": {
				"left": nil,
				"right": nil,
				"straight": nil
			}
		}
	}
}

channel addVehicle {
	out vehicles(vehicles: Map, addVehicle(id: Str, road: Str, turn: Str)) = insert(vehicles, id, {"road": road, "turn": turn, "nextTurn": ""})
	out roads.dynamic.{road}.{turn}(roadVehicles: Map, addVehicle(id, road, turn)) = insert(raodVehicles, id, true)
}

channel turn(vid: Str){
	out vehicles.{vid}.nextTurn(cur: Str, turn(next: Str)) = next
}

channel turn2 { 
	in vehicles.{vid}.nextTurn(cur: Str, turn2(nextTurn: Str, road: Str, turn: Str, nextRoad: Str)) = nextTurn
	ref vehicles.{vid}.road(curRoad: Str, turn2(nextTurn, curRoad, turn, nextRoad))
	ref vehicles.{vid}.turn(curTurn: Str, turn2(nextTurn, road, curTurn, nextRoad))
	ref roads.static.{road}.{turn}(nextRoad: Str, turn2(nextTurn, road, turn, nextRoad))
	out vehicles.{vid}.turn(cur: Str, turn2(nextTurn, road, turn, nextRoad)) = nextTurn
	out roads.dynamic.{road}.{turn}.{vid}(curV: Bool, turn2(nextTurn, road, turn, nextRoad)) = false
	out roads.dynamic.{nextRoad}.{nextTurn}(roadVehicles: Map, turn2(nextTurn, road, turn, nextRoad)) = insert(roadVehicles, vid, true)
}





