The persistent cosmic web and its filamentary structure - I. Theory and implementation | Synapse