section ‹Generic DFS and Refinement› theory General_DFS_Structure imports "../../Param_DFS" begin text ‹ We define the generic structure of DFS algorithms, and use this to define a notion of refinement between DFS algorithms. › (* Generic plot: Define generic DFS-scheme (paramDFS is instance) Make basic assumptions on DFS scheme parameters: discovered increasing, new_root_discovered, … Show how to implement scheme by FOREACH/WHILE, etc This gives a generic implementation for all things that follow basic DFS scheme Then define simplified DFS-variants (using general DFS scheme): With on-stack, without on-stack Also refine without on-stack to restriction (?) Orthogonal refinements: 1. Refine algorithmic structure, operations remain the same: i.e. fe_impl, rec_impl, ... 2. Refine operations, structure remains the same: Special case: Refine operations while keeping parametrization *) named_theorems DFS_code_unfold ‹DFS framework: Unfolding theorems to prepare term for automatic refinement› (*ML {* structure DFS_code_unfold = Named_Thms ( val name = @{binding DFS_code_unfold} val description = "DFS framework: Unfolding theorems to prepare term for automatic refinement" ) *} setup DFS_code_unfold.setup*) (* Basic setup *) lemmas [DFS_code_unfold] = REC_annot_def (* TODO: Setup REC_annot for autoref!*) GHOST_elim_Let (* TODO: Unfold in autoref. Can we (ab)use autoref_op_pat_def for that *) comp_def (* TODO: Setup transfer package to handle this ((RETURN o f) x) *) subsection ‹Generic DFS Algorithm›