Theory Ordered_Resolution

theory Ordered_Resolution
  imports
    First_Order_Clause.Nonground_Order
    First_Order_Clause.Nonground_Selection_Function
    First_Order_Clause.Nonground_Typing
    First_Order_Clause.Typed_Tiebreakers
    Saturation_Framework.Lifting_to_Non_Ground_Calculi
  
    Ground_Ordered_Resolution
begin

locale ordered_resolution_calculus =
  witnessed_nonground_typing where
  welltyped = welltyped and term_to_ground = "term_to_ground :: 't  'tG" and
  id_subst = "id_subst :: 'subst" +

  nonground_order where lesst = lesst +

  nonground_selection_function where
  select = select and atom_subst = "(⋅t)" and atom_vars = term.vars and
  atom_from_ground = term.from_ground and atom_to_ground = term.to_ground +
  tiebreakers tiebreakers
for
  select :: "'t select" and
  lesst :: "'t  't  bool" and
  tiebreakers :: "('tG, 't) tiebreakers" and
  welltyped :: "('v :: infinite, 'ty) var_types  't  'ty  bool"
begin

inductive factoring :: "('t, 'v, 'ty) typed_clause  ('t, 'v, 'ty) typed_clause  bool" where
  factoringI: 
  "D = add_mset l1 (add_mset l2 D') 
   l1 = Pos t1 
   l2 = Pos t2 
   C = (add_mset l1 D')  μ 
   factoring (𝒱, D) (𝒱, C)"
if
  "select D = {#}"
  "is_maximal (l1 ⋅l μ) (D  μ)"
  "type_preserving_on (clause.vars D) 𝒱 μ" 
  "term.is_imgu μ {{t1, t2}}"

inductive resolution ::
  "('t, 'v, 'ty) typed_clause 
   ('t, 'v, 'ty) typed_clause 
   ('t, 'v, 'ty) typed_clause  bool" where
  resolutionI: 
  "E = add_mset l1 E' 
   D = add_mset l2 D' 
   l1 = Neg t1 
   l2 = Pos t2 
   C = (E'  ρ1 + D'  ρ2)  μ 
   resolution (𝒱2, D) (𝒱1, E) (𝒱3, C)"
if
  "infinite_variables_per_type 𝒱1"
  "infinite_variables_per_type 𝒱2"
  "term.is_renaming ρ1"
  "term.is_renaming ρ2"
  "clause.vars (E  ρ1)  clause.vars (D  ρ2) = {}"
  "type_preserving_on (clause.vars (E  ρ1)  clause.vars (D  ρ2)) 𝒱3 μ" 
  "term.is_imgu μ {{t1 ⋅t ρ1, t2 ⋅t ρ2}}"
  "¬ (E  ρ1  μ c D  ρ2  μ)"
  "select E = {#}  is_maximal (l1 ⋅l ρ1  μ) (E  ρ1  μ)"
  "select E  {#}  is_maximal (l1 ⋅l ρ1  μ) ((select E)  ρ1  μ)"
  "select D = {#}"
  "is_strictly_maximal (l2 ⋅l ρ2  μ) (D  ρ2  μ)"
  "x  clause.vars E. 𝒱1 x = 𝒱3 (term.rename ρ1 x)"
  "x  clause.vars D. 𝒱2 x = 𝒱3 (term.rename ρ2 x)"
  "type_preserving_on (clause.vars E) 𝒱1 ρ1"
  "type_preserving_on (clause.vars D) 𝒱2 ρ2"

abbreviation factoring_inferences where
 "factoring_inferences  { Infer [D] C | D C. factoring D C }"

abbreviation resolution_inferences where
 "resolution_inferences  { Infer [D, E] C | D E C. resolution D E C }"

definition inferences :: "('t, 'v, 'ty) typed_clause inference set" where
 "inferences  resolution_inferences  factoring_inferences"

abbreviation bottomF :: "('t, 'v, 'ty) typed_clause set" ("F") where
  "bottomF  {(𝒱, {#}) | 𝒱. infinite_variables_per_type 𝒱 }"

end

end