text\<open> Fixrec patterns can mention any constructor defined by the domain
package, as well as any of the following built-in constructors:
Pair, spair, sinl, sinr, up, ONE, TT, FF. \<close>
text\<open>Typical usage is with lazy constructors.\<close>
fixrec down :: "'a u \ 'a" where"down\(up\x) = x"
text\<open>With strict constructors, rewrite rules may require side conditions.\<close>
text\<open>\<open>fixrec_simp\<close> is useful for producing strictness theorems.\<close> text\<open>Note that pattern matching is done in left-to-right order.\<close>
subsection \<open>Pattern matching with bottoms\<close>
text\<open>
As an alternative tousing\<open>fixrec_simp\<close>, it is also possible touse bottom as a constructor pattern. When using a bottom
pattern, the right-hand-side must also be bottom; otherwise, \<open>fixrec\<close> will not be able to prove the equation. \<close>
text\<open> If the functionis already strict in that argument, then the bottom
pattern does not change the meaning of the function. For example, in the definition of \<^term>\<open>from_sinr_up\<close>, the first equation is
actually redundant, and could have been proven separately by \<open>fixrec_simp\<close>. \<close>
text\<open>
A bottom pattern can also be used to make a function strict in a
certain argument, similar to a bang-pattern in Haskell. \<close>
subsection \<open>Skipping proofs of rewrite rules\<close>
text\<open>Another zip function for lazy lists.\<close>
text\<open>
Notice that this version has overlapping patterns.
The second equation cannot be proved as a theorem
because it only applies when the first pattern fails. \<close>
text\<open>
Usually fixrec tries to prove all equations as theorems.
The "unchecked" option overrides this behavior, so fixrec
does not attempt to prove that particular equation. \<close>
text\<open>Simp rules can be generated later using \<open>fixrec_simp\<close>.\<close>
text\<open>
The defining equations of a fixrecdefinition are declared as simp
rules by default. In some cases, especially for constants with no
arguments or functions with variable patterns, the defining
equations may cause the simplifier to loop. In these cases it will
be necessary touse a \<open>[simp del]\<close> declaration. \<close>
fixrec
repeat :: "'a \ 'a llist" where
[simp del]: "repeat\x = lCons\x\(repeat\x)"
text\<open>
We can derive other non-looping simp rules for\<^const>\<open>repeat\<close> by using the \<open>subst\<close> method with the \<open>repeat.simps\<close> rule. \<close>
lemma repeat_simps [simp]: "repeat\x \ \" "repeat\x \ lNil" "repeat\x = lCons\y\ys \ x = y \ repeat\x = ys" by (subst repeat.simps, simp)+
lemma llist_case_repeat [simp]: "llist_case\z\f\(repeat\x) = f\x\(repeat\x)" by (subst repeat.simps, simp)
text\<open> For mutually-recursive constants, looping might only occur if all
equations are in the simpset at the same time. In such cases it may
only be necessary todeclare\<open>[simp del]\<close> on one equation. \<close>
locale test = fixes foo :: "'a \ 'a" assumes foo_strict: "foo\\ = \" begin
fixrec
bar :: "'a u \ 'a" where "bar\(up\x) = foo\x"
lemma bar_strict: "bar\\ = \" by fixrec_simp
end
end
¤ 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.14Bemerkung:
(vorverarbeitet)
¤
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 ist noch experimentell.