proposition: Lemma list_gt_list_is_sound : forall p lg ls, match list_gt_list p lg ls with | Some true => forall s, In s ls -> exists g, In g lg /\ p g s = Some Greater_than | _ => True end.
proof: Proof. intros p lg ls; revert lg; induction ls as [ | s ls]; intro lg. simpl; intros; contradiction. unfold list_gt_list; simpl. generalize (list_exists_option_is_sound (fun g : term => match p g s with | Some Equivalent => Some false | Some Less_than => Some false | Some Greater_than => Some true | Some Uncomparable => Some false | None => None end) lg). destruct (list_exists_option (fun g : term => match p g s with | Some Equivalent => Some false | Some Less_than => Some false | Some Greater_than => Some true | Some Uncomparable => Some false | None => None end) lg) as [[ | ] | ]. intros [g [g_in_ls H]]. generalize (IHls lg); unfold list_gt_list; destruct (list_forall_option (fun s0 : term => list_exists_option (fun g0 : term => match p g0 s0 with | Some Equivalent => Some false | Some Less_than => Some false | Some Greater_than => Some true | Some Uncomparable => Some false | None => None end) lg) ls) as [[ | ] | ]. intros H' u [s_eq_u | u_in_ls]. subst u; exists g; split; trivial. destruct (p g s) as [[ | | | ] | ]; (apply eq_refl || discriminate). apply H'; assumption. trivial. trivial. intros _; destruct (list_forall_option (fun s0 : term => list_exists_option (fun g0 : term => match p g0 s0 with | Some Equivalent => Some false | Some Less_than => Some false | Some Greater_than => Some true | Some Uncomparable => Some false | None => None end) lg) ls) as [[ | ] | ]; trivial. trivial. Qed.
imports: Coq(Bool Peano List PeanoNat) CoLoR(closure more_list equiv_list list_permut dickson) Coq(Relations Wellfounded Arith Wf_nat Recdef Program Morphisms Lia) CoLoR(term_spec term decidable_set ordered_set NatCompat)