Skip to content

Commit

Permalink
Add rose_reduce, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
binghe committed Jan 22, 2025
1 parent 0f92f96 commit 3c81597
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/coalgebras/ltreeScript.sml
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,16 @@ Proof
\\ fs [EVERY_MEM,MEM_MAP,PULL_EXISTS]
QED

local
val thm = Q.prove (‘!t. ltree_finite t ==> ?r. from_rose r = t’,
METIS_TAC [ltree_finite_from_rose]);
in
(* |- !t. ltree_finite t ==> from_rose (to_rose t) = t *)
val to_rose_def = new_specification
("to_rose_def", ["to_rose"],
SIMP_RULE bool_ss [GSYM RIGHT_EXISTS_IMP_THM, SKOLEM_THM] thm);
end;

Definition rose_node_def[simp] :
rose_node (Rose a ts) = a
End
Expand All @@ -995,6 +1005,13 @@ Definition rose_children_def[simp] :
rose_children (Rose a ts) = ts
End

(* This is a general recursive reduction function for rose trees *)
Definition rose_reduce_def :
rose_reduce f ((Rose a ts) :'a rose_tree) = f a (MAP (rose_reduce f) ts)
Termination
WF_REL_TAC ‘measure (rose_tree_size (\x. 0) o SND)’
End

(* tidy up theory exports *)

val _ = List.app Theory.delete_binding
Expand Down

0 comments on commit 3c81597

Please sign in to comment.