isabelle - How to defined a constructive predicate for a map? -


here 2 simple predicates:

definition map_is_empty :: "(string ⇒ nat option) ⇒ bool"   "map_is_empty env ≡ ∀x. env x = none"  value "map_is_empty map.empty" value "map_is_empty [''x''↦1]"  definition map_is_less_5 :: "(string ⇒ nat option) ⇒ bool"   "map_is_less_5 env ≡ ∀x. ∃y. env x = y ∧ y < 5"  value "map_is_less_5 [''x''↦1,''y''↦2]" value "map_is_less_5 [''x''↦1,''y''↦2,''z''↦7]" 

the problem value returns errors such as:

wellsortedness error (in code equation map_is_empty ?env ≡ ∀x. option.is_none (?env x), dependency "pure.dummy_pattern" -> "map_is_empty"): type char list not of sort enum no type arity list :: enum 

how define these predicates able evaluate them using value or values?

maybe ~~/src/hol/library/finite_map , ~~/src/hol/library/mapping can help, similar errors using them.

~~/src/hol/library/finfun seems ideal task, same error:

definition ff_is_empty :: "(string ⇒f nat option) ⇒ bool"   "ff_is_empty env ≡ ∀x. env $ x = none"  value "ff_is_empty (k$ none)" 

i've got it! ~~/src/hol/library/finfun great. details can found in this presentation. @ "formalising finfuns – generating code functions data isabelle/hol" andreas lochbihler.

for each predicate 1 must define lemma replacing finfun_all. lemma used code generation:

definition ff_is_empty :: "(string ⇒f nat option) ⇒ bool"   "ff_is_empty env ⟷ (∀x. env $ x = none)"  lemma ff_is_empty_code [code]:   "ff_is_empty env ⟷ finfun_all ((λx. x = none) ∘$ env)"   (auto simp add: ff_is_empty_def finfun_all_all)  value "ff_is_empty (k$ none)" value "ff_is_empty (k$ none)(''x'' $:= 1)"  fun option_less :: "nat option ⇒ nat ⇒ bool"   "option_less (some a) b = (a < b)" | "option_less _ _ = true"  definition ff_is_less_5 :: "(string ⇒f nat option) ⇒ bool"   "ff_is_less_5 env ⟷ (∀x. option_less (env $ x) 5)"  lemma ff_is_less_5_code [code]:   "ff_is_less_5 env ⟷ finfun_all ((λx. option_less x 5) ∘$ env)"   (auto simp add: ff_is_less_5_def finfun_all_all)  value "ff_is_less_5 (k$ none)(''x'' $:= 1)" value "ff_is_less_5 (k$ none)(''x'' $:= 1)(''y'' $:= 2)(''z'' $:= 7)" 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -