Theory PAC_Polynomials_Term
theory PAC_Polynomials_Term
  imports PAC_Polynomials
    Refine_Imperative_HOL.IICF
begin
section ‹Terms›
text ‹We define some helper functions.›
subsection ‹Ordering›
lemma fref_to_Down_curry_left:
  fixes f:: ‹'a ⇒ 'b ⇒ 'c nres› and
    A::‹(('a × 'b) × 'd) set›
  shows
    ‹(uncurry f, g) ∈ [P]⇩f A → ⟨B⟩nres_rel ⟹
      (⋀a b x'. P x' ⟹ ((a, b), x') ∈ A ⟹ f a b ≤ ⇓ B (g x'))›
  unfolding fref_def uncurry_def nres_rel_def
  by auto
lemma fref_to_Down_curry_right:
  fixes g :: ‹'a ⇒ 'b ⇒ 'c nres› and f :: ‹'d ⇒ _ nres› and
    A::‹('d × ('a × 'b)) set›
  shows
    ‹(f, uncurry g) ∈ [P]⇩f A → ⟨B⟩nres_rel ⟹
      (⋀a b x'. P (a,b) ⟹ (x', (a, b)) ∈ A ⟹ f x' ≤ ⇓ B (g a b))›
  unfolding fref_def uncurry_def nres_rel_def
  by auto
type_synonym term_poly_list = ‹string list›
type_synonym llist_polynomial = ‹(term_poly_list × int) list›
text ‹We instantiate the characters with typeclass linorder to be able to talk abourt sorted and
  so on.›
definition less_eq_char :: ‹char ⇒ char ⇒ bool› where
  ‹less_eq_char c d = (((of_char c) :: nat) ≤ of_char d)›
definition less_char :: ‹char ⇒ char ⇒ bool› where
  ‹less_char c d = (((of_char c) :: nat) < of_char d)›