A selective chemosensor and fluorescence probe for relay recognition of cations and fluoride ions in aqueous media with logic gate function.