Theory Abstract_Formula
section ‹Derivatives of Abstract Formulas›
theory Abstract_Formula
imports
Automaton
Deriving.Compare_Instances
"HOL-Library.Code_Target_Nat"
While_Default
begin
subsection ‹Preliminaries›
lemma pred_Diff_0[simp]: "0 ∉ A ⟹ i ∈ (λx. x - Suc 0) ` A ⟷ Suc i ∈ A"
by (cases i) (fastforce simp: image_iff le_Suc_eq elim: contrapos_np)+
lemma funpow_cycle_mult: "(f ^^ k) x = x ⟹ (f ^^ (m * k)) x = x"
by (induct m) (auto simp: funpow_add)
lemma funpow_cycle: "(f ^^ k) x = x ⟹ (f ^^ l) x = (f ^^ (l mod k)) x"
by (subst div_mult_mod_eq[symmetric, of l k])
(simp only: add.commute funpow_add funpow_cycle_mult o_apply)
lemma funpow_cycle_offset:
fixes f :: "'a ⇒ 'a"
assumes "(f ^^ k) x = (f ^^ i) x" "i ≤ k" "i ≤ l"
shows "(f ^^ l) x = (f ^^ ((l - i) mod (k - i) + i)) x"
proof -
from assms have
"(f ^^ (k - i)) ((f ^^ i) x) = ((f ^^ i) x)"
"(f ^^ l) x = (f ^^ (l - i)) ((f ^^ i) x)"
unfolding fun_cong[OF funpow_add[symmetric, unfolded o_def]] by simp_all
from funpow_cycle[OF this(1), of "l - i"] this(2) show ?thesis
by (simp add: funpow_add)
qed
lemma in_set_tlD: "x ∈ set (tl xs) ⟹ x ∈ set xs"
by (cases xs) auto
definition "dec k m = (if m > k then m - Suc 0 else m :: nat)"
subsection ‹Abstract formulas›