Theory OpUbx

theory OpUbx
  imports OpInl Unboxed
begin


section β€Ήn-ary operationsβ€Ί

locale nary_operations_ubx =
  nary_operations_inl 𝔒𝔭 𝔄𝔯𝔦𝔱𝔢 ℑ𝔫𝔩𝔒𝔭 ℑ𝔫𝔩 ℑ𝔰ℑ𝔫𝔩 𝔇𝔒ℑ𝔫𝔩 +
  unboxedval unitialized is_true is_false box_ubx1 unbox_ubx1 box_ubx2 unbox_ubx2
  for
    𝔒𝔭 :: "'op β‡’ 'dyn list β‡’ 'dyn" and 𝔄𝔯𝔦𝔱𝔢 and
    ℑ𝔫𝔩𝔒𝔭 and ℑ𝔫𝔩 and ℑ𝔰ℑ𝔫𝔩 and 𝔇𝔒ℑ𝔫𝔩 :: "'opinl β‡’ 'op" and
    unitialized :: 'dyn and is_true and is_false and
    box_ubx1 :: "'ubx1 β‡’ 'dyn" and unbox_ubx1 and
    box_ubx2 :: "'ubx2 β‡’ 'dyn" and unbox_ubx2 +
  fixes
    π”˜π”Ÿπ”΅π”’π”­ :: "'opubx β‡’ ('dyn, 'ubx1, 'ubx2) unboxed list β‡’ ('dyn, 'ubx1, 'ubx2) unboxed option" and
    π”˜π”Ÿπ”΅ :: "'opinl β‡’ type option list β‡’ 'opubx option" and
    𝔅𝔬𝔡 :: "'opubx β‡’ 'opinl" and
    𝔗𝔢𝔭𝔒𝔒𝔣𝔒𝔭 :: "'opubx β‡’ type option list Γ— type option"
  assumes
    π”˜π”Ÿπ”΅_invertible:
      "π”˜π”Ÿπ”΅ opinl ts = Some opubx ⟹ 𝔅𝔬𝔡 opubx = opinl" and
    π”˜π”Ÿπ”΅π”’π”­_correct:
      "π”˜π”Ÿπ”΅π”’π”­ opubx Ξ£ = Some z ⟹ ℑ𝔫𝔩𝔒𝔭 (𝔅𝔬𝔡 opubx) (map norm_unboxed Ξ£) = norm_unboxed z" and
    π”˜π”Ÿπ”΅π”’π”­_to_ℑ𝔫𝔩:
      "π”˜π”Ÿπ”΅π”’π”­ opubx Ξ£ = Some z ⟹ ℑ𝔫𝔩 (𝔇𝔒ℑ𝔫𝔩 (𝔅𝔬𝔡 opubx)) (map norm_unboxed Ξ£) = Some (𝔅𝔬𝔡 opubx)" and
    
    𝔗𝔢𝔭𝔒𝔒𝔣𝔒𝔭_𝔄𝔯𝔦𝔱𝔢:
      "𝔄𝔯𝔦𝔱𝔢 (𝔇𝔒ℑ𝔫𝔩 (𝔅𝔬𝔡 opubx)) = length (fst (𝔗𝔢𝔭𝔒𝔒𝔣𝔒𝔭 opubx))" and
    π”˜π”Ÿπ”΅_opubx_type:
      "π”˜π”Ÿπ”΅ opinl ts = Some opubx ⟹ fst (𝔗𝔢𝔭𝔒𝔒𝔣𝔒𝔭 opubx) = ts" and

    𝔗𝔢𝔭𝔒𝔒𝔣𝔒𝔭_correct:
      "𝔗𝔢𝔭𝔒𝔒𝔣𝔒𝔭 opubx = (map typeof xs, Ο„) ⟹
        βˆƒy. π”˜π”Ÿπ”΅π”’π”­ opubx xs = Some y ∧ typeof y = Ο„" and
    𝔗𝔢𝔭𝔒𝔒𝔣𝔒𝔭_complete:
      "π”˜π”Ÿπ”΅π”’π”­ opubx xs = Some y ⟹ 𝔗𝔢𝔭𝔒𝔒𝔣𝔒𝔭 opubx = (map typeof xs, typeof y)"

end