fact: Definition solve pb : list matching_problem := match unsolved_part pb with | (tt1,tt2 as e) :: list_of_equations => match tt1, tt2 with | Var x, _ => match find X.eq_bool x (solved_part pb) with | Some x_val => if T.eq_bool x_val tt2 then let new_pb := mk_pb (existential_vars pb) list_of_equations (solved_part pb) (partly_solved_part pb) in new_pb :: nil else nil | None => match find X.eq_bool x (partly_solved_part pb) with | Some x_part_val => match tt2 with | Var _ => nil | Term f2 l2 => if F.Symb.eq_bool (head_symb x_part_val) f2 then let y := new_var x_part_val in match remove T.eq_bool (closed_term x_part_val) l2 with | Some rmv => let y_val := build f2 rmv in let new_pb := mk_pb (existential_vars pb) ((Var y, y_val) :: list_of_equations) (solved_part pb) (partly_solved_part pb) in new_pb :: nil | None => nil end else nil end | None => let new_pb := mk_pb (existential_vars pb) list_of_equations ((x, tt2) :: (solved_part pb)) (partly_solved_part pb) in new_pb :: nil end end | Term f1 l1, Term f2 l2 => if F.Symb.eq_bool f1 f2 then match arity f1 with | Free _ => match fold_left2 (fun current_list_of_eqs t1 t2 => (t1,t2) :: current_list_of_eqs) list_of_equations l1 l2 with | Some new_list_of_equations => let new_pb := mk_pb (existential_vars pb) new_list_of_equations (solved_part pb) (partly_solved_part pb) in new_pb :: nil | None => nil end | AC => if le_gt_dec (length l1) (length l2) then ac_elementary_solve pb tt1 tt2 list_of_equations else nil | C => match l1, l2 with | (s1 :: s2 :: nil), (t1 :: t2 :: nil) => let new_pb1 := mk_pb (existential_vars pb) ((s1,t1) :: (s2,t2) :: list_of_equations) (solved_part pb) (partly_solved_part pb) in let new_pb2 := mk_pb (existential_vars pb) ((s1,t2) :: (s2,t1) :: list_of_equations) (solved_part pb) (partly_solved_part pb) in new_pb1 :: new_pb2 :: nil | _, _ => nil end end else nil | _, _ => nil end | nil => nil end.
imports: Coq(Arith List) CoLoR(more_list list_sort term_spec ac cf_eq_ac)