fact
stringlengths
6
103k
type
stringclasses
14 values
library
stringclasses
13 values
imports
listlengths
1
10
filename
stringclasses
157 values
symbolic_name
stringlengths
1
54
docstring
stringclasses
185 values
rev_tac_condFs_ok := match goal with | |- is_unary _ => is_unary Fs_ok | |- rules_preserve_vars _ => rules_preserve_vars | |- WF _ => idtac end.
Ltac
Conversion
[ "From CoLoR Require Import Srs ATrs SReverse ATerm_of_String String_of_ATerm", "From CoLoR Require Import AVariables" ]
Conversion/AReverse.v
rev_tac_cond
null
rev_tacFs_ok := (rewrite <- WF_red_rev_eq || rewrite <- WF_red_mod_rev_eq); rev_tac_cond Fs_ok.
Ltac
Conversion
[ "From CoLoR Require Import Srs ATrs SReverse ATerm_of_String String_of_ATerm", "From CoLoR Require Import AVariables" ]
Conversion/AReverse.v
rev_tac
null
ar(_ : letter) := 1. Import ATrs.
Definition
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
ar
corresponding algebraic signature
ASig_of_SSig:= mkSignature ar (@VSignature.beq_symb_ok SSig). Notation ASig := ASig_of_SSig. Notation term := (term ASig). Notation terms := (vector term). Notation context := (context ASig). Import AUnary.
Definition
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
ASig_of_SSig
null
is_unary_sig: is_unary ASig. Proof. intro. refl. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
is_unary_sig
null
arity:= arity1 is_unary_sig.
Ltac
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
arity
null
is_unary:= try (exact is_unary_sig). Notation Fun1 := (Fun1 is_unary_sig). Notation Cont1 := (Cont1 is_unary_sig). Notation cont := (cont is_unary_sig). Notation term_ind_forall := (term_ind_forall is_unary_sig).
Ltac
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
is_unary
null
term_of_string(s : string) : term := match s with | List.nil => Var 0 | a :: w => @Fun ASig a (Vcons (term_of_string w) Vnil) end.
Fixpoint
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
term_of_string
conversion string <-> term
var_term_of_string: forall s, var (term_of_string s) = 0. Proof. induction s; auto. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
var_term_of_string
null
reset_term_of_string: forall s, reset (term_of_string s) = term_of_string s. Proof. induction s. refl. unfold reset. simpl. apply args_eq. fold (reset (term_of_string s)). rewrite IHs. refl. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
reset_term_of_string
null
string_of_term(t : term) : string := match t with | Var _ => List.nil | Fun f ts => f :: Vmap_first List.nil string_of_term ts end.
Fixpoint
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
string_of_term
null
string_of_term_epi: forall s, string_of_term (term_of_string s) = s. Proof. induction s; simpl; intros. refl. rewrite IHs. refl. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
string_of_term_epi
null
term_of_string_epi: forall t, maxvar t = 0 -> term_of_string (string_of_term t) = t. Proof. intro t; pattern t; apply term_ind_forall; clear t. simpl in *. intros. subst. refl. intros f t IH. unfold AUnary.Fun1. simpl. rewrite (Vcast_cons (is_unary_sig f)), Vcast_refl. simpl. rewrite max_0_r. intro h. rewrite (IH h). refl. Qed. Arguments term_of_string_epi [t] _.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
term_of_string_epi
null
string_of_term_sub: forall s l, string_of_term (sub s l) = string_of_term l ++ string_of_term (s (var l)). Proof. intro s. apply term_ind_forall. refl. intros f t IH. rewrite sub_fun1. simpl. rewrite !(Vcast_cons (is_unary_sig f)). simpl. rewrite IH. refl. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
string_of_term_sub
null
string_of_cont(c : context) : string := match c with | Hole => List.nil | @Cont _ f _ _ _ _ d _ => f :: string_of_cont d end.
Fixpoint
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
string_of_cont
conversion string <-> context
string_of_cont_cont: forall t, string_of_cont (cont t) = string_of_term t. Proof. apply term_ind_forall. refl. intros f t IH. simpl. rewrite !(Vcast_cons (is_unary_sig f)). simpl. rewrite IH. refl. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
string_of_cont_cont
null
string_of_term_fill: forall t c, string_of_term (fill c t) = string_of_cont c ++ string_of_term t. Proof. induction c. refl. simpl. rewrite Vmap_first_cast. arity. simpl. rewrite IHc. refl. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
string_of_term_fill
null
cont_of_string(s : string) : context := match s with | List.nil => Hole | a :: w => Cont1 a (cont_of_string w) end.
Fixpoint
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
cont_of_string
null
sub_of_strings := single 0 (term_of_string s).
Definition
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
sub_of_string
conversion string <-> substitution
term_of_string_fill: forall c s, term_of_string (SContext.fill c s) = fill (cont_of_string (lft c)) (sub (sub_of_string (rgt c)) (term_of_string s)). Proof. intros [l r] s. elim l; unfold SContext.fill; simpl. elim s. refl. intros. simpl. rewrite H. refl. intros. rewrite H, (Vcast_cons (cont_aux is_unary_sig a)), Vcast_refl. refl. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
term_of_string_fill
null
term_of_string_app: forall s1 s2, term_of_string (s1 ++ s2) = sub (sub_of_string s2) (term_of_string s1). Proof. induction s1. refl. intro. simpl. apply args_eq. rewrite IHs1. refl. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
term_of_string_app
null
rule_of_srule(x : srule) := mkRule (term_of_string (Srs.lhs x)) (term_of_string (Srs.rhs x)).
Definition
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
rule_of_srule
rules
trs_of_srsR := List.map rule_of_srule R.
Definition
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
trs_of_srs
null
rules_preserve_vars_trs_of_srs: forall R, rules_preserve_vars (trs_of_srs R). Proof. unfold rules_preserve_vars. induction R; simpl; intuition. unfold rule_of_srule in H0. destruct a. simpl in H0. inversion H0. rewrite !vars_var; is_unary. rewrite !var_term_of_string. unfold incl; simpl; intuition. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
rules_preserve_vars_trs_of_srs
null
preserve_vars:= try (apply rules_preserve_vars_trs_of_srs).
Ltac
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
preserve_vars
null
red_of_sred: forall x y, Srs.red R x y -> red (trs_of_srs R) (term_of_string x) (term_of_string y). Proof. intros. do 3 destruct H. decomp H. subst x. subst y. rewrite !term_of_string_fill. apply red_rule. change (List.In (rule_of_srule (Srs.mkRule x0 x1)) (trs_of_srs R)). unfold trs_of_srs. apply in_map. exact H0. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
red_of_sred
null
rtc_red_of_sred: forall x y, Srs.red R # x y -> red (trs_of_srs R) # (term_of_string x) (term_of_string y). Proof. intros. elim H; intros. apply rt_step. apply red_of_sred. exact H0. apply rt_refl. eapply rt_trans. apply H1. exact H3. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
rtc_red_of_sred
null
sred_of_red: forall t u, red (trs_of_srs R) t u -> Srs.red R (string_of_term t) (string_of_term u). Proof. intros. redtac. subst. rewrite !string_of_term_fill, !string_of_term_sub, (rules_preserve_vars_var is_unary_sig (rules_preserve_vars_trs_of_srs R) lr). set (c' := mkContext (string_of_cont c) (string_of_term (s (var l)))). change (Srs.red R (SContext.fill c' (string_of_term l)) (SContext.fill c' (string_of_term r))). apply Srs.red_rule. clear c'. destruct (in_map_elim lr). destruct H. destruct x. unfold rule_of_srule in H0. simpl in H0. inversion H0. rewrite !string_of_term_epi. hyp. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
sred_of_red
null
rtc_sred_of_red: forall t u, red (trs_of_srs R) # t u -> Srs.red R # (string_of_term t) (string_of_term u). Proof. induction 1. apply rt_step. apply sred_of_red. hyp. apply rt_refl. apply rt_trans with (string_of_term y); hyp. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
rtc_sred_of_red
null
red_mod_of_sred_mod: forall x y, Srs.red_mod E R x y -> red_mod (trs_of_srs E) (trs_of_srs R) (term_of_string x) (term_of_string y). Proof. intros. do 2 destruct H. exists (term_of_string x0). split. apply rtc_red_of_sred. exact H. apply red_of_sred. exact H0. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
red_mod_of_sred_mod
null
WF_red_mod_of_WF_sred_mod: WF (red_mod (trs_of_srs E) (trs_of_srs R)) -> WF (Srs.red_mod E R). Proof. unfold WF. intro H. cut (forall t s, t = term_of_string s -> SN (Srs.red_mod E R) s). intros. apply H0 with (term_of_string x). refl. intro t. gen (H t). induction 1. intros. apply SN_intro. intros. apply H1 with (term_of_string y). 2: refl. subst x. apply red_mod_of_sred_mod. exact H3. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
WF_red_mod_of_WF_sred_mod
null
sred_mod_of_red_mod: forall t u, red_mod (trs_of_srs E) (trs_of_srs R) t u -> Srs.red_mod E R (string_of_term t) (string_of_term u). Proof. intros. do 2 destruct H. exists (string_of_term x); split. apply rtc_sred_of_red. hyp. apply sred_of_red. hyp. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
sred_mod_of_red_mod
preservation of termination
WF_sred_mod_of_WF_red_mod: WF (Srs.red_mod E R) -> WF (red_mod (trs_of_srs E) (trs_of_srs R)). Proof. intro. rewrite WF_red_mod0; is_unary; preserve_vars. cut (forall s, SN (Srs.red_mod E R) s -> forall t, maxvar t = 0 -> t = term_of_string s -> SN (red_mod0 (trs_of_srs E) (trs_of_srs R)) t). intros. intro t. destruct (eq_nat_dec (maxvar t) 0). 2: apply SN_intro; intros ? []; lia. apply H0 with (string_of_term t). apply H. hyp. rewrite term_of_string_epi. refl. hyp. induction 1; intros. apply SN_intro; intros. assert (h : maxvar y = 0). apply (red_mod0_maxvar (rules_preserve_vars_trs_of_srs E) (rules_preserve_vars_trs_of_srs R) H4). rewrite <- (term_of_string_epi h). apply H1 with (string_of_term y). 3: refl. 2: rewrite (term_of_string_epi h); hyp. rewrite <- (string_of_term_epi x). apply sred_mod_of_red_mod. subst. eapply incl_elim with (R := red_mod0 (trs_of_srs E) (trs_of_srs R)). apply red_mod0_incl_red_mod. hyp. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
WF_sred_mod_of_WF_red_mod
null
WF_red_mod: WF (Srs.red_mod E R) <-> WF (red_mod (trs_of_srs E) (trs_of_srs R)). Proof. split; intro. apply WF_sred_mod_of_WF_red_mod. hyp. apply WF_red_mod_of_WF_sred_mod. hyp. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
WF_red_mod
null
WF_red: WF (Srs.red R) <-> WF (red (trs_of_srs R)). Proof. rewrite <- Srs.red_mod_empty, <- red_mod_empty. apply WF_red_mod. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
WF_red
null
as_trs:= rewrite WF_red_mod || rewrite WF_red.
Ltac
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN VecUtil ListUtil NatUtil" ]
Conversion/ATerm_of_String.v
as_trs
tactics for Rainbow
beq_statuss1 s2 := match s1, s2 with | Lex, Lex | Mul, Mul => true | _, _ => false end.
Definition
Conversion
[ "From CoLoR Require Import LogicUtil ATerm VecUtil", "From CoLoR Require Import term_spec EqUtil", "From CoLoR Require Import NatUtil", "From Stdlib Require Import List Relations", "From CoLoR Require Import term SN ASubstitution", "From CoLoR Require Import rpo rpo_extension", "From CoLoR Require Import ARedPair ARelation RelUtil BoolUtil" ]
Conversion/Coccinelle.v
beq_status
decide compatibility of statuses wrt precedences
beq_status_ok: forall s1 s2, beq_status s1 s2 = true <-> s1 = s2. Proof. beq_symb_ok. Qed.
Lemma
Conversion
[ "From CoLoR Require Import LogicUtil ATerm VecUtil", "From CoLoR Require Import term_spec EqUtil", "From CoLoR Require Import NatUtil", "From Stdlib Require Import List Relations", "From CoLoR Require Import term SN ASubstitution", "From CoLoR Require Import rpo rpo_extension", "From CoLoR Require Import ARedPair ARelation RelUtil BoolUtil" ]
Conversion/Coccinelle.v
beq_status_ok
null
prec_eq_statuss p o := apply (bprec_eq_status_ok s p o); check_eq || fail 10 "statuses incompatible with precedences".
Ltac
Conversion
[ "From CoLoR Require Import LogicUtil ATerm VecUtil", "From CoLoR Require Import term_spec EqUtil", "From CoLoR Require Import NatUtil", "From Stdlib Require Import List Relations", "From CoLoR Require Import term SN ASubstitution", "From CoLoR Require Import rpo rpo_extension", "From CoLoR Require Import ARedPair ARelation RelUtil BoolUtil" ]
Conversion/Coccinelle.v
prec_eq_status
null
as_srs_condFs_ok := match goal with | |- is_unary _ => is_unary Fs_ok | |- rules_preserve_vars _ => rules_preserve_vars | |- WF _ => idtac end.
Ltac
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN ListUtil Srs ATrs AUnary VecUtil", "From CoLoR Require Import AVariables" ]
Conversion/String_of_ATerm.v
as_srs_cond
null
as_srsFs_ok := (rewrite WF_red_mod || rewrite WF_red); as_srs_cond Fs_ok.
Ltac
Conversion
[ "From CoLoR Require Import LogicUtil RelUtil SN ListUtil Srs ATrs AUnary VecUtil", "From CoLoR Require Import AVariables" ]
Conversion/String_of_ATerm.v
as_srs
null
co_scc:= check_eq || fail 10 "not a co_scc". From CoLoR Require Import AVariables.
Ltac
DP
[ "From CoLoR Require Import AGraph Union ATrs RelUtil ListUtil LogicUtil SN", "From CoLoR Require Import AVariables" ]
DP/ADecomp.v
co_scc
tactics
graph_decompSig f d := apply WF_decomp_co_scc with (approx := f) (cs := d); [idtac | rules_preserve_vars | incl_rule Sig || fail 10 "the decomposition does not contain all DPs" | incl_rule Sig || fail 10 "the decomposition contains a rule that is not a DP" | check_eq || fail 10 "the decomposition is not valid" | unfold lforall; repeat split].
Ltac
DP
[ "From CoLoR Require Import AGraph Union ATrs RelUtil ListUtil LogicUtil SN", "From CoLoR Require Import AVariables" ]
DP/ADecomp.v
graph_decomp
null
negb_subterm(t u : term) := negb (bsubterm u t).
Definition
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
negb_subterm
definition of dependancy pairs
mkdp(S : rules) : rules := match S with | nil => nil | a :: S' => let (l, r) := a in map (mkRule l) (filter (negb_subterm l) (calls R r)) ++ mkdp S' end.
Fixpoint
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
mkdp
null
dp:= mkdp R.
Definition
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
dp
null
mkdp_app: forall l1 l2, mkdp (l1 ++ l2) = mkdp l1 ++ mkdp l2. Proof. induction l1; simpl; intros. refl. destruct a as [l r]. rewrite app_ass, IHl1. refl. Qed.
Lemma
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
mkdp_app
null
mkdp_elim: forall l t S, In (mkRule l t) (mkdp S) -> exists r, In (mkRule l r) S /\ In t (calls R r) /\ negb_subterm l t = true. Proof. induction S; simpl; intros. contr. destruct a. rewrite in_app in H. destruct H. destruct (in_map_elim H). destruct H0. injection H1. intros. subst x. subst lhs. clear H1. rewrite filter_In in H0. destruct H0. exists rhs. intuition. destruct (IHS H). destruct H0. destruct H1. exists x. intuition. Qed. Arguments mkdp_elim [l t S] _.
Lemma
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
mkdp_elim
null
dp_intro: forall l r t, In (mkRule l r) R -> In t (calls R r) -> negb_subterm l t = true -> In (mkRule l t) dp. Proof. intros. ded (in_elim H). do 2 destruct H2. ded (in_elim H0). do 2 destruct H3. unfold dp. rewrite H2, mkdp_app. simpl. rewrite H3, filter_app, map_app. simpl. rewrite H1. apply in_appr. apply in_appl. apply in_appr. apply in_eq. Qed.
Lemma
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
dp_intro
basic properties
dp_elim: forall l t, In (mkRule l t) dp -> exists r, In (mkRule l r) R /\ In t (calls R r) /\ negb_subterm l t = true. Proof. intros. apply mkdp_elim. hyp. Qed. Arguments dp_elim [l t] _.
Lemma
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
dp_elim
null
in_calls_hd_red_dp: forall l r t s, In (mkRule l r) R -> In t (calls R r) -> negb_subterm l t = true -> hd_red dp (sub s l) (sub s t). Proof. intros. exists l. exists t. exists s. intuition. eapply dp_intro. apply H. hyp. hyp. Qed.
Lemma
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
in_calls_hd_red_dp
null
lhs_dp: incl (map lhs dp) (map lhs R). Proof. unfold incl. intros. ded (in_map_elim H). do 2 destruct H0. subst a. destruct x as [l r]. ded (dp_elim H0). do 2 destruct H1. change (In (lhs (mkRule l x)) (map lhs R)). apply in_map. exact H1. Qed. (*FIXME: to be finished
Lemma
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
lhs_dp
null
is_notvar_lhs_dp_aux: forall S, forallb (@is_notvar_lhs Sig) (mkdp S) = true. Proof. induction S; simpl; intros. refl. destruct a. simpl. rewrite forallb_app. Qed.
Lemma
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
is_notvar_lhs_dp_aux
null
is_notvar_lhs_dp: forallb (@is_notvar_lhs Sig) dp = true. Proof. unfold dp. Qed.*)
Lemma
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
is_notvar_lhs_dp
null
chain:= int_red R # @ hd_red dp.
Definition
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
chain
dependency chains
in_calls_chain: forall l r t s, In (mkRule l r) R -> In t (calls R r) -> negb_subterm l t = true -> chain (sub s l) (sub s t). Proof. intros. unfold chain, compose. exists (sub s l). split. apply rt_refl. eapply in_calls_hd_red_dp. apply H. hyp. hyp. Qed.
Lemma
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
in_calls_chain
null
gt_chain: forall f ts us v, Vrel1 (red R) ts us -> chain (Fun f us) v -> chain (Fun f ts) v. Proof. unfold chain, compose. intros. do 2 destruct H0. exists x. split. apply rt_trans with (y := Fun f us). apply rt_step. apply Vgt_prod_fun. exact H. exact H0. exact H1. Qed.
Lemma
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
gt_chain
null
chain_mins t := chain s t /\ lforall (SN (red R)) (direct_subterms s) /\ lforall (SN (red R)) (direct_subterms t).
Definition
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
chain_min
minimal dependency chain (subterms are terminating)
chain_min_incl_chain: chain_min << chain. Proof. red. intros x y cmin. elim cmin. auto. Qed.
Lemma
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
chain_min_incl_chain
null
gt_chain_min: forall f ts us v, Vrel1 (red R) ts us -> Vforall (SN (red R)) ts -> chain_min (Fun f us) v -> chain_min (Fun f ts) v. Proof. intros f ts us v gt_ts_us sn_ts chain_min_fus_v. unfold chain_min in chain_min_fus_v. destruct chain_min_fus_v as [chain_fus_v sn]. destruct sn as [esn_us esn_ts]. unfold chain_min. split. apply gt_chain with us; trivial. split. simpl. apply Vforall_lforall in sn_ts. trivial. trivial. Qed. Variable hyp1 : forallb (@is_notvar_lhs Sig) R = true. Variable hyp2 : rules_preserve_vars R. Arguments hyp2 [l r] _ _ _.
Lemma
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
gt_chain_min
null
dp_elim_vars: forall l t, In (mkRule l t) dp -> exists r, In (mkRule l r) R /\ In t (calls R r) /\ negb_subterm l t = true /\ incl (vars t) (vars l). Proof. intros. destruct (dp_elim H). decomp H0. exists x. intuition. trans (vars x). unfold incl. intros. eapply subterm_eq_vars. eapply in_calls_subterm. apply H3. hyp. apply hyp2. hyp. Qed. Arguments dp_elim_vars [l t] _.
Lemma
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
dp_elim_vars
dp preserves variables
dp_preserve_vars: rules_preserve_vars dp. Proof. unfold rules_preserve_vars. intros. destruct (dp_elim_vars H). intuition. Qed. Notation capa := (capa R). Notation cap := (cap R). Notation alien_sub := (alien_sub R). Notation SNR := (SN (red R)).
Lemma
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
dp_preserve_vars
null
chain_min_fun: forall f, defined f R = true -> forall ts, SN chain_min (Fun f ts) -> Vforall SNR ts -> SNR (Fun f ts). Proof. cut (forall t, SN chain_min t -> forall f, defined f R = true -> forall ts, t = Fun f ts -> Vforall SNR ts -> SNR t). intros. apply H with (f := f) (ts := ts); (hyp || refl). intros t H. elim H. clear t H. intros t H IH f H0 ts H1 Hsnts. assert (SN (Vrel1 (red R)) ts). apply Vforall_SN_rel1. hyp. gen IH. rewrite H1. elim H2. clear IH ts H1 Hsnts H2. intros ts H1 IH1 IH2. assert (Hsnts : Vforall SNR ts). apply SN_rel1_forall. apply SN_intro. hyp. clear H1. assert (H1 : forall y, Vrel1 (red R) ts y -> SNR (Fun f y)). intros. apply IH1. hyp. intros. eapply IH2. eapply gt_chain_min. apply H1. trivial. apply H2. apply H3. apply H4. hyp. clear IH1. apply SN_intro. intros u H2. redtac. destruct c; simpl in xl, yr. destruct (fun_eq_sub xl). destruct e as [ls]. rewrite H2, sub_fun in xl. Funeqtac. assert (Hsnsx : forall x, In x (vars l) -> SNR (s x)). intros. eapply sub_fun_sn with (f := f). subst l. apply H4. rewrite H3 in Hsnts. exact Hsnts. subst u. assert (r = sub (alien_sub r) (cap r)). apply sym_eq. apply (alien_sub_cap R). rewrite H4, sub_sub. apply no_call_sub_sn. hyp. apply calls_cap. intros. ded (vars_cap R H5). case (le_lt_dec x (maxvar r)); intro; unfold sub_comp, ACap.alien_sub. ded (vars_cap_inf R H5 l0). ded (hyp2 lr _ H7). rewrite fsub_inf. simpl. apply Hsnsx. hyp. hyp. rewrite (fsub_nth (aliens (capa r)) l0 H6). set (a := Vnth (aliens (capa r)) (lt_pm (k:=projT1 (capa r)) l0 H6)). assert (Fun f ts = sub s l). rewrite H3, H2. refl. assert (In a (calls R r)). apply aliens_incl_calls. unfold a. apply Vnth_in. ded (in_calls H8). destruct H9 as [g]. destruct H9 as [vs]. destruct H9. eapply calls_sn with (r := r). hyp. intros. apply Hsnsx. apply (hyp2 lr _ H11). intros h ws H13 H14. case_eq (negb_subterm l (Fun h ws)); intros. rename H11 into z. apply IH2 with (y := Fun h (Vmap (sub s) ws)) (f := h) (ts := Vmap (sub s) ws). unfold chain_min. split. rewrite H7, <- sub_fun. eapply in_calls_chain. apply lr. hyp. hyp. split. simpl. apply Vforall_lforall. trivial. simpl. apply Vforall_lforall. trivial. eapply in_calls_defined. apply H13. refl. hyp. revert H11. unfold negb_subterm. rewrite negb_lr. simpl negb. rewrite bsubterm_ok. intro H11. rewrite H2 in H11. destruct (subterm_fun_elim H11). destruct H12. apply subterm_eq_sn with (t := sub s x0). eapply Vforall_in. apply Hsnts. rewrite H3. apply Vin_map_intro. hyp. apply subterm_eq_sub. hyp. hyp. decomp e. subst l. is_var_lhs. Funeqtac. subst u. apply H1. rewrite H2. apply Vrel1_cast_intro. apply Vrel1_app_intro_l. apply Vrel1_cons_intro. left. split. eapply red_rule. hyp. refl. Qed.
Lemma
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
chain_min_fun
null
chain_fun: forall f, defined f R = true -> forall ts, SN chain (Fun f ts) -> Vforall SNR ts -> SNR (Fun f ts). Proof. intros f defined_f ts sn_chain_f_ts sn_ts. apply chain_min_fun; auto. apply (SN_incl chain). apply chain_min_incl_chain. hyp. Qed.
Lemma
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
chain_fun
null
WF_chain: WF chain -> WF (red R). Proof. intro Hwf. unfold WF. apply term_ind_forall. apply sn_var. apply hyp1. intro f. case_eq (defined f R); intros. apply chain_fun. hyp. apply Hwf. hyp. apply sn_args_sn_fun; auto. Qed.
Lemma
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
WF_chain
null
chain_hd_red_mod: chain << hd_red_mod R dp. Proof. unfold chain, hd_red_mod. comp. apply rtc_incl. apply int_red_incl_red. Qed.
Lemma
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
chain_hd_red_mod
null
chain:= no_relative_rules; apply WF_chain; [ check_eq || fail 10 "a LHS is a variable" | rules_preserve_vars | idtac].
Ltac
DP
[ "From CoLoR Require Import LogicUtil ATrs ACalls ACap ASN RelUtil ListUtil", "From CoLoR Require Import AVariables" ]
DP/ADP.v
chain
null
hyp': rules_preserve_vars DP. Proof. apply dp_preserve_vars. exact hyp. Qed.
Lemma
DP
[ "From Stdlib Require Import Lia", "From CoLoR Require Import LogicUtil ATrs ListUtil RelUtil RelSub Path ARelation", "From CoLoR Require Export ADP" ]
DP/ADPGraph.v
hyp'
null
dp_grapha1 a2 := In a1 DP /\ In a2 DP /\ exists p, exists s, int_red R # (sub s (rhs a1)) (sub s (shift p (lhs a2))).
Definition
DP
[ "From Stdlib Require Import Lia", "From CoLoR Require Import LogicUtil ATrs ListUtil RelUtil RelSub Path ARelation", "From CoLoR Require Export ADP" ]
DP/ADPGraph.v
dp_graph
dependancy pairs graph
restricted_dp_graph: is_restricted dp_graph DP. Proof. unfold is_restricted, dp_graph, inclusion. intros. intuition. Qed.
Lemma
DP
[ "From Stdlib Require Import Lia", "From CoLoR Require Import LogicUtil ATrs ListUtil RelUtil RelSub Path ARelation", "From CoLoR Require Export ADP" ]
DP/ADPGraph.v
restricted_dp_graph
null
chain_dpa t u := In a DP /\ exists s, int_red R # t (sub s (lhs a)) /\ u = sub s (rhs a).
Definition
DP
[ "From Stdlib Require Import Lia", "From CoLoR Require Import LogicUtil ATrs ListUtil RelUtil RelSub Path ARelation", "From CoLoR Require Export ADP" ]
DP/ADPGraph.v
chain_dp
chain relation for a given dependency pair
chain_dp_chain: forall a, chain_dp a << Chain. Proof. unfold inclusion. intros. destruct H. do 2 destruct H0. exists (sub x0 (lhs a)). intuition. subst y. destruct a. simpl. apply hd_red_rule. exact H. Qed.
Lemma
DP
[ "From Stdlib Require Import Lia", "From CoLoR Require Import LogicUtil ATrs ListUtil RelUtil RelSub Path ARelation", "From CoLoR Require Export ADP" ]
DP/ADPGraph.v
chain_dp_chain
null
chain_chain_dp: forall t u, Chain t u -> exists a, chain_dp a t u. Proof. intros. do 2 destruct H. redtac. subst x. subst u. exists (mkRule l r). unfold chain_dp. simpl. intuition. exists s. intuition. Qed.
Lemma
DP
[ "From Stdlib Require Import Lia", "From CoLoR Require Import LogicUtil ATrs ListUtil RelUtil RelSub Path ARelation", "From CoLoR Require Export ADP" ]
DP/ADPGraph.v
chain_chain_dp
null
chain_dps(a : rule) (l : rules) : relation term := match l with | nil => chain_dp a | b :: m => chain_dp a @ chain_dps b m end.
Fixpoint
DP
[ "From Stdlib Require Import Lia", "From CoLoR Require Import LogicUtil ATrs ListUtil RelUtil RelSub Path ARelation", "From CoLoR Require Export ADP" ]
DP/ADPGraph.v
chain_dps
iteration of chain steps given a list of dependency pairs
chain_dps_app: forall l a b m, chain_dps a (l ++ b :: m) << chain_dps a l @ chain_dps b m. Proof. induction l; simpl; intros. refl. assoc. comp. apply IHl. Qed. Arguments chain_dps_app [l a b m] _ _ _.
Lemma
DP
[ "From Stdlib Require Import Lia", "From CoLoR Require Import LogicUtil ATrs ListUtil RelUtil RelSub Path ARelation", "From CoLoR Require Export ADP" ]
DP/ADPGraph.v
chain_dps_app
null
chain_dps_app': forall a l m b p, a :: l = m ++ b :: p -> chain_dps a l << chain_dps a (tail m) % @ chain_dps b p. Proof. intros. destruct m; simpl in H; injection H; unfold inclusion; intros. subst p. subst b. exists x. unfold clos_refl. intuition auto with *. subst r. subst l. simpl. ded (chain_dps_app _ _ H2). do 2 destruct H0. exists x0. unfold clos_refl. intuition auto with *. Qed. Arguments chain_dps_app' [a l m b p] _ [x y] _.
Lemma
DP
[ "From Stdlib Require Import Lia", "From CoLoR Require Import LogicUtil ATrs ListUtil RelUtil RelSub Path ARelation", "From CoLoR Require Export ADP" ]
DP/ADPGraph.v
chain_dps_app'
null
chain_dps_iter_chain: forall l a, chain_dps a l << iter Chain (length l). Proof. induction l; simpl; intros. apply chain_dp_chain. comp. apply chain_dp_chain. apply IHl. Qed.
Lemma
DP
[ "From Stdlib Require Import Lia", "From CoLoR Require Import LogicUtil ATrs ListUtil RelUtil RelSub Path ARelation", "From CoLoR Require Export ADP" ]
DP/ADPGraph.v
chain_dps_iter_chain
null
iter_chain_chain_dps: forall n t u, iter Chain n t u -> exists a, exists l, length l = n /\ chain_dps a l t u. Proof. induction n; simpl; intros. ded (chain_chain_dp H). destruct H0. exists x. exists nil. intuition. do 2 destruct H. ded (chain_chain_dp H). destruct H1. exists x0. ded (IHn _ _ H0). do 3 destruct H2. exists (x1 :: x2). simpl. intuition. exists x. intuition. Qed. Arguments iter_chain_chain_dps [n t u] _.
Lemma
DP
[ "From Stdlib Require Import Lia", "From CoLoR Require Import LogicUtil ATrs ListUtil RelUtil RelSub Path ARelation", "From CoLoR Require Export ADP" ]
DP/ADPGraph.v
iter_chain_chain_dps
null
chain_dp2_dp_graph: forall a1 a2 t u v, chain_dp a1 t u -> chain_dp a2 u v -> dp_graph a1 a2. Proof. intros. destruct a1 as [l0 r0]. destruct a2 as [l1 r1]. destruct H. simpl in H1. do 2 destruct H1. subst u. rename x into s0. destruct H0. simpl in H2. do 2 destruct H2. subst v. rename x into s1. unfold dp_graph. intuition. simpl. set (p := maxvar l0 + 1). exists p. (* take the union of s0 (restricted to [vars l0]) and [comp s1 (shift_inv_sub p l1)] (restricted to [vars (shift p l1)] *) set (s0' := restrict s0 (vars l0)). set (s1' := restrict (sub_comp s1 (shift_inv_sub p l1)) (vars (shift p l1))). set (s := ASubstitution.union s0' s1'). exists s. assert (compat s0' s1' (vars l0) (vars (shift p l1))). unfold compat. intros. ded (vars_max H3). ded (in_vars_shift_min H4). unfold p in H6. absurd (x <= maxvar l0). lia. hyp. assert (dom_incl s0' (vars l0)). unfold s0'. apply dom_incl_restrict. assert (dom_incl s1' (vars (shift p l1))). unfold s1'. apply dom_incl_restrict. assert (sub s r0 = sub s0' r0). unfold s. eapply sub_union1. apply H5. apply H3. apply hyp'. hyp. rewrite H6. assert (sub s0' r0 = sub s0 r0). unfold s0'. sym. apply sub_restrict_incl. apply hyp'. hyp. rewrite H7. assert (sub s (shift p l1) = sub s1' (shift p l1)). unfold s. eapply sub_union2. apply H4. apply H3. refl. rewrite H8. assert (sub s1' (shift p l1) = sub s1 l1). unfold s1'. rewrite <- sub_restrict, <- sub_shift. refl. rewrite H9. hyp. Qed.
Lemma
DP
[ "From Stdlib Require Import Lia", "From CoLoR Require Import LogicUtil ATrs ListUtil RelUtil RelSub Path ARelation", "From CoLoR Require Export ADP" ]
DP/ADPGraph.v
chain_dp2_dp_graph
two consecutive chain steps provide a dp_graph step
chain_dps_path_dp_graph: forall l a b t u, chain_dps a (l ++ b :: nil) t u -> path dp_graph a b l. Proof. induction l; simpl; intros; do 2 destruct H. eapply chain_dp2_dp_graph. apply H. apply H0. ded (IHl _ _ _ _ H0). intuition. destruct l; simpl in H0; do 2 destruct H0. eapply chain_dp2_dp_graph. apply H. apply H0. eapply chain_dp2_dp_graph. apply H. apply H0. Qed. Arguments chain_dps_path_dp_graph [l a b t u] _. (** hypotheses of the criterion based on cycles using the same reduction pair for every cycle *) Import ACompat. Variables (succ succ_eq : relation term) (Hredord : weak_rewrite_ordering succ succ_eq) (Hreword : rewrite_ordering succ_eq) (Habsorb : absorbs_left succ succ_eq) (HcompR : compat succ_eq R) (HcompDP : compat succ_eq (dp R)) (Hwf : WF succ) (Hcycle : forall a l, length l < length DP -> cycle_min dp_graph a l -> exists b, In b (a :: l) /\ succ (lhs b) (rhs b)). Notation eq_dec := (@eq_rule_dec Sig). Notation occur := (occur eq_dec).
Lemma
DP
[ "From Stdlib Require Import Lia", "From CoLoR Require Import LogicUtil ATrs ListUtil RelUtil RelSub Path ARelation", "From CoLoR Require Export ADP" ]
DP/ADPGraph.v
chain_dps_path_dp_graph
null
chain_dp_hd_red_mod: forall a, chain_dp a << hd_red_mod R (a::nil). Proof. unfold inclusion. intros. destruct H. do 2 destruct H0. subst y. destruct a. simpl. simpl in H0. exists (sub x0 lhs). split. apply incl_elim with (R := int_red R #). apply rtc_incl. apply int_red_incl_red. exact H0. apply hd_red_rule. simpl. auto. Qed.
Lemma
DP
[ "From Stdlib Require Import Lia", "From CoLoR Require Import LogicUtil ATrs ListUtil RelUtil RelSub Path ARelation", "From CoLoR Require Export ADP" ]
DP/ADPGraph.v
chain_dp_hd_red_mod
compatibility properties of chains
compat_chain_dp: forall a, chain_dp a << succ_eq#. Proof. intros. incl_trans (red_mod R DP). apply incl_trans with Chain; try incl_refl. apply chain_dp_chain. incl_trans (hd_red_mod R DP). apply chain_hd_red_mod. apply hd_red_mod_incl_red_mod. incl_trans (succ_eq!). apply compat_red_mod_tc; hyp. apply tc_incl_rtc. Qed.
Lemma
DP
[ "From Stdlib Require Import Lia", "From CoLoR Require Import LogicUtil ATrs ListUtil RelUtil RelSub Path ARelation", "From CoLoR Require Export ADP" ]
DP/ADPGraph.v
compat_chain_dp
null
compat_chain_dps: forall l a, chain_dps a l << succ_eq#. Proof. induction l; simpl; intros. apply compat_chain_dp. incl_trans (succ_eq# @ succ_eq#). comp. apply compat_chain_dp. apply IHl. apply comp_rtc_idem. Qed.
Lemma
DP
[ "From Stdlib Require Import Lia", "From CoLoR Require Import LogicUtil ATrs ListUtil RelUtil RelSub Path ARelation", "From CoLoR Require Export ADP" ]
DP/ADPGraph.v
compat_chain_dps
null
compat_chain_dp_strict: forall a, succ (lhs a) (rhs a) -> chain_dp a << succ. Proof. unfold inclusion. intros. destruct H0. do 2 destruct H1. subst y. apply (absorbs_left_rtc Habsorb). exists (sub x0 (lhs a)). split. apply incl_elim with (R := int_red R #). 2: exact H1. apply rtc_incl. incl_trans (red R). apply int_red_incl_red. apply compat_red; hyp. destruct Hredord. apply H2. exact H. Qed.
Lemma
DP
[ "From Stdlib Require Import Lia", "From CoLoR Require Import LogicUtil ATrs ListUtil RelUtil RelSub Path ARelation", "From CoLoR Require Export ADP" ]
DP/ADPGraph.v
compat_chain_dp_strict
null
WF_cycles: WF (chain R). Proof. set (n := length DP). apply WF_iter with (S n). intro. assert (Hwf' : WF (succ @ succ_eq#)). apply absorb_WF_modulo_r; hyp. gen (Hwf' x). induction 1. apply SN_intro; intros. apply H0. ded (iter_chain_chain_dps H1). do 3 destruct H2. assert (length x1 > 0). lia. ded (last_intro H4). do 3 destruct H5. clear H4. rewrite H5 in H3. ded (chain_dps_path_dp_graph H3). set (l' := x0 :: x2 ++ x3 :: nil). assert (exists z, occur z l' >= 2). unfold l'. eapply long_path_occur. apply restricted_dp_graph. apply H4. rewrite H6, H2. unfold n. lia. assert (exists l, exists a, exists m, l' = l ++ a :: m /\ succ (lhs a) (rhs a)). destruct H7. set (p := occur x4 l' - 2). assert (occur x4 l' = S (S p)). unfold p. lia. ded (occur_S eq_dec H8). do 3 destruct H9. destruct H10. clear H8. rewrite H9. ded (occur_S eq_dec H11). do 3 destruct H8. destruct H12. clear H11. clear H13. clear p. rewrite H8. rewrite H8 in H9. clear H8. clear H10. assert (cycle dp_graph x4 x7). unfold cycle. eapply sub_path. unfold l' in H9. apply H9. exact H4. ded (cycle_min_intro eq_dec H8). decomp H10. assert (length l' = n+2). unfold l'. simpl. rewrite <- H5. lia. rewrite H9 in H10. change (length (x5++(x4::x7)++x4::x8) = n+2) in H10. rewrite H11 in H10. repeat (rewrite length_app in H10; simpl in H10). unfold n in H10. assert (h : length x11 < length DP). unfold cycle_min in H14. destruct H14. assert (length (x10::x11) <= length DP). apply nodup_incl_length. apply eq_dec. exact H14. apply incl_appr_incl with (x10::nil). simpl. eapply restricted_path_incl. apply restricted_dp_graph. exact H13. simpl in H15. lia. clear H10. ded (Hcycle h H14). do 2 destruct H10. ded (in_elim H10). do 2 destruct H15. exists (x5++x9++x14). exists x13. exists (x15++x12++x4::x8). intuition. rewrite !app_ass. trans (x5++(x4::x7)++x4::x8). refl. rewrite H11, app_ass. trans (x5++x9++(x10::x11)++x12++x4::x8). simpl. rewrite app_ass. refl. rewrite H15, app_ass. refl. do 4 destruct H8. unfold l' in H8. ded (chain_dps_app' H8 H3). do 2 destruct H10. assert (succ_eq# x x7). destruct H10. subst x7. intuition auto with *. eapply incl_elim. eapply compat_chain_dps. apply H10. assert ((succ @ succ_eq#) x7 y). destruct x6; simpl in H11. ded (compat_chain_dp_strict H9 H11). exists y. intuition auto with *. do 2 destruct H11. exists x8. split. eapply incl_elim. apply (compat_chain_dp_strict H9). exact H11. eapply incl_elim. eapply compat_chain_dps. apply H13. do 2 destruct H13. exists x8. intuition. eapply incl_elim with (R := succ_eq# @ succ). apply absorbs_left_rtc. intuition. exists x7. intuition. Qed.
Lemma
DP
[ "From Stdlib Require Import Lia", "From CoLoR Require Import LogicUtil ATrs ListUtil RelUtil RelSub Path ARelation", "From CoLoR Require Export ADP" ]
DP/ADPGraph.v
WF_cycles
proof of the criterion based on cycles
dpg_unif_N_correct:= (apply dpg_unif_N_mark_correct || apply dpg_unif_N_correct); (check_eq || fail 10 "a LHS is a variable").
Ltac
DP
[ "From Stdlib Require Import Lia Compare_dec", "From CoLoR Require Import ADecomp AUnif ARenCap ATrs ListUtil RelUtil AGraph" ]
DP/ADPUnif.v
dpg_unif_N_correct
tactics
dp_trans:= chain; eapply WF_incl; [apply hd_red_Mod_of_chain | idtac].
Ltac
DP
[ "From CoLoR Require Import LogicUtil ATrs RelUtil RelSub SN AShift ADPGraph", "From CoLoR Require Export ADP", "From Stdlib Require Import List Lia" ]
DP/AGraph.v
dp_trans
tactics
hder1 r2 := In r1 D /\ In r2 D /\ match rhs r1 with | Var _ => True | Fun f _ => match lhs r2 with | Var _ => True | Fun g _ => f=g end end.
Definition
DP
[ "From CoLoR Require Import ADecomp ADuplicateSymb ATrs ListUtil RelSub RelUtil" ]
DP/AHDE.v
hde
null
hde_restricted: is_restricted hde D. Proof. unfold is_restricted. intros. unfold hde in H; tauto. Qed. Notation eq_rule_dec := (@eq_rule_dec Sig). Notation eq_symb_dec := (@eq_symb_dec Sig).
Lemma
DP
[ "From CoLoR Require Import ADecomp ADuplicateSymb ATrs ListUtil RelSub RelUtil" ]
DP/AHDE.v
hde_restricted
null
hde_dec: forall r1 r2, {hde r1 r2} + {~hde r1 r2}. Proof. intros. unfold hde. destruct (In_dec eq_rule_dec r1 D); try tauto. destruct (In_dec eq_rule_dec r2 D); try tauto. destruct (rhs r1). left; auto. destruct (lhs r2); auto. destruct (eq_symb_dec f f0); try tauto. Defined.
Lemma
DP
[ "From CoLoR Require Import ADecomp ADuplicateSymb ATrs ListUtil RelSub RelUtil" ]
DP/AHDE.v
hde_dec
null
int_red_hd_rules_graph_incl_hde: hd_rules_graph (int_red R #) D << hde D. Proof. unfold inclusion. intros. destruct x. destruct y. destruct H. destruct H0. do 2 destruct H1. unfold hde. destruct lhs0; destruct rhs; simpl; auto. intuition; auto. ded (int_red_rtc_preserve_hd H1). destruct H2. simpl in H2. inversion H2; auto. do 4 destruct H2. inversion H2. inversion H3. congruence. Qed.
Lemma
DP
[ "From CoLoR Require Import ADecomp ADuplicateSymb ATrs ListUtil RelSub RelUtil" ]
DP/AHDE.v
int_red_hd_rules_graph_incl_hde
null
dup_hd_rules_graph_incl_hde: hd_rules_graph (red R #) D << hde D. Proof. unfold inclusion. intros. apply (@int_red_hd_rules_graph_incl_hde _ R D x y). destruct H. decomp H0. rewrite forallb_forall in hd_hyp. ded (hd_hyp _ H). compute in H0. destruct x. destruct rhs. discr. destruct f. unfold hd_rules_graph. intuition. exists x0. exists x1. simpl rhs. rewrite sub_fun. apply dup_int_rules_int_red_rtc; hyp. discr. Qed.
Lemma
DP
[ "From CoLoR Require Import ADecomp ADuplicateSymb ATrs ListUtil RelSub RelUtil" ]
DP/AHDE.v
dup_hd_rules_graph_incl_hde
null
hd_eq(u v : term Sig) := match u with | Var _ => true | Fun f _ => match v with | Var _ => true | Fun g _ => beq_symb f g end end. Notation mem := (mem (@beq_rule Sig)). Notation mem_ok := (mem_ok (@beq_rule_ok Sig)).
Definition
DP
[ "From CoLoR Require Import ADecomp ADuplicateSymb ATrs ListUtil RelSub RelUtil" ]
DP/AHDE.v
hd_eq
null
hde_boolr1 r2 := mem r1 D && mem r2 D && hd_eq (rhs r1) (lhs r2).
Definition
DP
[ "From CoLoR Require Import ADecomp ADuplicateSymb ATrs ListUtil RelSub RelUtil" ]
DP/AHDE.v
hde_bool
null
hde_bool_correct_aux: forall x y, hde D x y <-> Graph hde_bool x y. Proof. intros x y. unfold hde, hde_bool, hd_eq, Graph; simpl. pose proof (fun s x y => proj1 (@beq_symb_ok s x y)). pose proof (fun s x y => proj2 (@beq_symb_ok s x y)). rewrite <- !mem_ok. destruct (rhs x); bool; intuition auto with core; repeat match goal with | H : _ && _ = true |- _ => apply andb_elim in H; case H as [] | H : _ = true |- _ => rewrite H; cbn [andb] | H : match ?x in term _ return _ with _ => _ end |- _ => case x eqn:? in *; subst | H : match ?x in term _ return _ with _ => _ end = true |- _ => case x eqn:? in *; subst end; auto. Qed.
Lemma
DP
[ "From CoLoR Require Import ADecomp ADuplicateSymb ATrs ListUtil RelSub RelUtil" ]
DP/AHDE.v
hde_bool_correct_aux
null
hde_bool_correct: hd_rules_graph (int_red R #) D << Graph (hde_bool D). Proof. incl_trans (hde D). apply int_red_hd_rules_graph_incl_hde. intros x y. rewrite hde_bool_correct_aux. auto. Qed. Notation Sig' := (dup_sig Sig). Notation R' := (dup_int_rules R). Variable hyp : forallb (@is_notvar_lhs Sig') R' = true.
Lemma
DP
[ "From CoLoR Require Import ADecomp ADuplicateSymb ATrs ListUtil RelSub RelUtil" ]
DP/AHDE.v
hde_bool_correct
null
hde_bool_mark_correct: hd_rules_graph (red (dup_int_rules R) #) (dup_hd_rules D) << Graph (hde_bool (dup_hd_rules D)). Proof. incl_trans (hde (dup_hd_rules D)). 2:{ intros x y. rewrite hde_bool_correct_aux. auto. } intros x y h. destruct h. decomp H0. unfold hde. intuition. destruct (in_map_elim H). destruct H0. destruct x2. unfold dup_hd_rule in H3. simpl in H3. subst x. simpl in *. destruct (in_map_elim H1). destruct H3. destruct x. unfold dup_hd_rule in H4. simpl in H4. subst y. simpl in *. destruct rhs; simpl. trivial. destruct lhs0; simpl. trivial. simpl dup_hd_term in H2. unfold shift in H2. rewrite !sub_fun in H2. destruct (rtc_red_dup_int_hd_symb hyp H2). Funeqtac. auto. Qed.
Lemma
DP
[ "From CoLoR Require Import ADecomp ADuplicateSymb ATrs ListUtil RelSub RelUtil" ]
DP/AHDE.v
hde_bool_mark_correct
null
hde_bool_correct:= (apply hde_bool_mark_correct || apply hde_bool_correct); (check_eq || fail 10 "a LHS is a variable").
Ltac
DP
[ "From CoLoR Require Import ADecomp ADuplicateSymb ATrs ListUtil RelSub RelUtil" ]
DP/AHDE.v
hde_bool_correct
tactics
use_SCC_tagh M S R t := let x := fresh in (set (x := SCC_tag_fast h M t); norm_in x (SCC_tag_fast h M t); match eval compute in x with | Some ?X1 => let Hi := fresh in (assert (Hi : X1 < length R); [ norm (length R); lia | let L := fresh in (set (L := SCC_list_fast R M Hi); norm_in L (SCC_list_fast R M Hi); assert (WF (hd_red_Mod S L)); subst L; clear Hi; clear x)]) end).
Ltac
DP
[ "From Stdlib Require Import Permutation Multiset Setoid PermutSetoid", "From CoLoR Require Import SCCTopoOrdering AGraph ATrs RelUtil RelSub BoundNat" ]
DP/ASCCUnion.v
use_SCC_tag
tactics
use_SCC_hypM l := let b := fresh "b" in (set (b := Vnth (Vnth M l) l); norm_in b (Vnth (Vnth M l) l); match eval compute in b with | false => apply WF_hd_red_Mod_SCC_fast_trivial with (Hi:=l); eauto | true => eapply WF_incl; [eapply hd_red_Mod_SCC'_hd_red_Mod_fast with (Hi:=l); auto | auto] end).
Ltac
DP
[ "From Stdlib Require Import Permutation Multiset Setoid PermutSetoid", "From CoLoR Require Import SCCTopoOrdering AGraph ATrs RelUtil RelSub BoundNat" ]
DP/ASCCUnion.v
use_SCC_hyp
null