section‹Examples of Rensets and Renaming-Based Recursion›
theory Examples imports FRBCE_Rensets Rensets begin
subsection‹Variables and terms as rensets›
text‹Variables form a renset: › interpretation Var: Renset where vsubstA = "vss" unfolding Renset_def vss_def by auto
text‹Terms form a renset: › interpretationTerm: Renset where vsubstA = "λt x. vsubst t x" unfolding Renset_def using subst_Vr subst_comp_same using fresh_subst_same subst_chain using subst_commute_diff by auto
text‹... and a CE renset: ›
interpretationTerm: CE_Renset where vsubstA = "λt x. subst t (Vr x)" and VrA = Vr and ApA = Ap and LmA = Lm apply standard by (auto simp add: Lm_subst_rename fresh_subst_same)
subsection‹ Interpretation in semantic domains›
type_synonym 'A I = "(var ==> 'A) ==> 'A"
locale Sem_Int = fixes ap :: "'A ==> 'A ==> 'A"and lm :: "('A ==> 'A) ==> 'A" begin
(* The target domain is a CE renset: *) sublocale CE_Renset where vsubstA = "λs x y ξ. s (ξ (y := ξ x))" and VrA = "λx ξ. ξ x" and ApA = "λi1 i2 ξ. ap (i1 ξ) (i2 ξ)" and LmA = "λx i ξ. lm (λd. i (ξ(x:=d)))" by standard (auto simp: fun_eq_iff fun_upd_twist intro!: arg_cong[of _ _ lm])
text‹ A functor applied to a renset yields a renset -- actually,
"local functor", i.e., one that is functorial
.r.t. functions on the substitutive set's carrier only, suffices. ›
locale Local_Functor = fixes Fmap :: "('A ==> 'A) ==> 'FA ==> 'FA" assumes Fmap_id: "Fmap id = id" and Fmap_comp: "Fmap (g o f) = Fmap g o Fmap f" begin
lemma Fmap_comp': "Fmap (g o f) k = Fmap g (Fmap f k)" using Fmap_comp by auto
end(* context Local_Functor *)
locale Renset_plus_Local_Functor =
Renset vsubstA + Local_Functor Fmap for vsubstA :: "'A ==> var ==> var ==> 'A" and Fmap :: "('A ==> 'A) ==> 'FA ==> 'FA" begin
(* The new renset with carrier 'A F: *) sublocale F: Renset where vsubstA = "λk x y. Fmap (λa. vsubstA a x y) k" apply standard
subgoal by (metis Fmap_id eq_id_iff vsubstA_id)
subgoal unfolding Fmap_comp'[symmetric] o_def by simp
subgoal unfolding Fmap_comp'[symmetric] o_def by (simp add: vsubstA_chain)
subgoal unfolding Fmap_comp'[symmetric] o_def using vsubstA_commute_diff by force .
end(* context Renset_plus_Local_Functor *)
subsection‹ The length of a term via renaming-based recursion ›
(* The target domain is a CE substitutive set: *) interpretation length : CE_Renset where vsubstA = "λn x y. n" and VrA = "λx. 1" and ApA = "λn1 n2. max n1 n2 + 1" and LmA = "λx n. n + 1" apply standard by auto
subsection‹ Counting the lambda-abstractions in a term via renaming-based recursion ›
(* The target domain is a CE substitutive set: *) interpretation clam : CE_Renset where vsubstA = "λn x y. n" and VrA = "λx. 0" and ApA = "λn1 n2. n1 + n2" and LmA = "λx n. n + 1" apply standard by auto
subsection‹ Counting free occurences of a variable in a term via renaming-based recursion ›
(* Counting the number of free occurrences of a variable in a term *) (* The target domain is a CE substitutive set: *) interpretation cfv : CE_Renset where vsubstA = "λf z y. λx. if x ∉ {y,z} then f x else if x = z ∧ x ≠ y then f x + f y else if x = y ∧ x ≠ z then (0::nat) else f y" and VrA = "λy. λx. if x = y then 1 else 0" and ApA = "λf1 f2. λx. f1 x + f2 x" and LmA = "λy f. λx. if x = y then 0 else f x" apply standard by (auto simp: fun_eq_iff)
subsection‹ Substitution via renaming-based recursion ›
(* The target domain is a CE substitutive set: *) locale Subst = fixes s :: trm and x :: var begin
sublocale ssb : BCE_Renset where vsubstA = "vsubst" and VrA = "λy. if y = x then s else Vr y" and ApA = "Ap" and LmA = "Lm" and X = "FFvars s ∪ {x}" apply standard by (auto simp: fun_eq_iff cofinite_fresh Term.LmA_rename)
(* We actually already have the substitution operator defined,
and the one defined above can be proved to be the same as this: *)
lemma subst_eq_ssb: "subst t s x = ssb.f t" proof- have"(λt. subst t s x) = ssb.f" apply(rule ssb.f_unique) by auto thus ?thesis unfolding fun_eq_iff by auto qed
end(* context Subst *)
subsection‹ Parrallel substitution via renaming-based recursion ›
(* The target domain is a CE substitutive set: *) locale PSubst = fixes ρ :: fenv begin
definition X where "X = supp ρ ∪∪ {FFvars (get ρ x) | x . x ∈ supp ρ}"
sublocale canEta' : BCE_Renset where vsubstA = "vsubst" and VrA = "λy. get ρ y" and ApA = "Ap" and LmA = "Lm" and X = "X" apply standard by (auto simp: fun_eq_iff cofinite_fresh finite_Supp Term.LmA_rename X_def finite_supp)
(metis fresh_subst_id mem_Collect_eq subst_Vr supp_get)
definition canEta :: "trm ==> bool"where "canEta t ≡∃x s. t = Lm x (Ap s (Vr x)) ∧ canEta'.f s ((λ_. True)(x:=False))"
end
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.4Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.