40 minutes is obviously pretty tight, but if everything aligns, you can probably make the connection. Of course, it depends on circumstances/details.
Variables:
- Does your inbound flight arrive on time (or even early)? AS is pretty good about that.
- Can you nab a seat towards the front of the plane on the first leg? That can save you 5-10 minutes right there (waiting to get off the plane).
- What gates do your flights typically use? Check to see if you will need to ride the train or can just hop over a short distance on foot.
Remember, if it's all booked on one ticket, worst case they would try to get you on the next flight. Check to see if there's a later flight that same day (so you don't have to wait overnight).