Theory Datatype_Selectors
theory Datatype_Selectors
imports Main
begin
text‹
Running Example: ‹datatype_new iptrule_match = is_Src: Src (src_range: ipt_iprange)›
A discriminator ‹disc› tells whether a value is of a certain constructor.
Example: ‹is_Src›
A selector ‹sel› select the inner value.
Example: ‹src_range›
A constructor ‹C› constructs a value
Example: ‹Src›
The are well-formed if the belong together.
›
fun wf_disc_sel :: "(('a ⇒ bool) × ('a ⇒ 'b)) ⇒ ('b ⇒ 'a) ⇒ bool" where
"wf_disc_sel (disc, sel) C ⟷ (∀a. disc a ⟶ C (sel a) = a) ∧ (∀a. sel (C a) = a)"
declare wf_disc_sel.simps[simp del]
end