(* A Invertibility for sequents, First-Order *) theory InvertibleNominal imports "SequentDepthNominal" begin (* Constructing the rule set we will use. It contains all axioms, but only a subset of the possible logical rules. *) lemma ruleSet: assumes "R1 \ propRules" and "R2 \ nprovRules" and "R3 \ provRules" and "R = idRules \ R1 \ R2 \ R3" and "(Ps,C) \ R*" shows "\ S r. extendRule S r = (Ps,C) \ (r \ R1 \ r \ R2 \ r \ R3 \ r \ idRules)" proof- from `(Ps,C) \ R*` have "\ S r. extendRule S r = (Ps,C) \ r \ R" by (cases) auto then obtain S r where "(Ps,C) = extendRule S r" and "r \ R" apply auto by (drule_tac x=S in meta_spec,drule_tac x=a in meta_spec, drule_tac x=b in meta_spec) auto moreover from `r \ R` and `R = idRules \ R1 \ R2 \ R3` have "r \ R1 \ r \ R2 \ r \ R3 \ r \ idRules" by blast ultimately show ?thesis by (rule_tac x=S in exI,rule_tac x=r in exI) (auto) qed (* Non-principal rule lemma *) lemma nonPrincipalInvertRight: assumes "R1 \ propRules" and "R2 \ nprovRules" and "R3 \ provRules" and "R = idRules \ R1 \ R2 \ R3" and "r \ R1 \ r \ R2 \ r \ R3" and "r = (ps,c)" and IH: "\m\ \. ( \ \* \ \ F \ [x].A, m) \ derivable R* \ (\r' \ R. rightPrincipal r' (F \ [x].A) \ ( \' \* \') \ set (fst r')) \ (\ multSubst \' \ \ multSubst \') \ (\m'\m. ( \ + \' \* \ + \', m') \ derivable R*)" and a': "(\ \* \ \ F \ [x].A,n) \ derivable R*" and b': "\ r' \ R. rightPrincipal r' (F \ [x].A) \ (\' \* \') \ set (fst r')" and c': "\ multSubst \' \ \ multSubst \'" and np: "\ rightPrincipal r (F \ [x].A)" and ext: "extendRule S r = (Ps,\ \* \ \ F \ [x].A)" and num: "n = n' + 1" and all: "\ p \ set Ps. \ n\n'. (p,n) \ derivable R*" and nonempty: "Ps \ []" shows "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" proof- from ext obtain \ \ where "S = (\ \* \)" by (cases S) (auto) from `r = (ps,c)` obtain G H where "c = (G \* H)" by (cases c) (auto) then have "{# F \ [x].A #} \ H" using `r \ R1 \ r \ R2 \ r \ R3` proof- {assume "r \ R1" then have "r \ propRules" using `R1 \ propRules` by auto with `r = (ps,c)` obtain T Ts where "c = ({#} \* {#Cpd0 T Ts#}) \ c = ({#Cpd0 T Ts#} \* {#})" using propRuleCharacterise[where Ps=ps and C=c] by auto moreover {assume "c = ({#} \* {#Cpd0 T Ts#})" with `c = (G \* H)` have "{# F \ [x].A #} \ H" by auto } moreover {assume "c = ({#Cpd0 T Ts#} \* {#})" then have "{#F \ [x].A #} \ H" using `c = (G \* H)` by auto } ultimately have "{# F \ [x].A #} \ H" by blast } moreover {assume "r \ R2 \ r \ R3" then have "r \ provRules \ r \ nprovRules" using `R2 \ nprovRules` and `R3 \ provRules` by auto with `r = (ps,c)` obtain T y B where "c = ({#} \* {# T \ [y].B #}) \ c = ({# T \ [y].B#} \* {#})" using provRuleCharacterise[where Ps=ps and C=c] and nprovRuleCharacterise[where Ps=ps and C=c] by auto moreover {assume "c = ({#} \* {# T \ [y].B#})" then have "rightPrincipal r (T \ [y].B)" using `r = (ps,c)` by auto with `\ rightPrincipal r (F \ [x].A)` have "T \ [y].B \ F \ [x].A" by auto with `c = (G \* H)` have "{# F \ [x].A #} \ H" using `c = ({#} \* {# T \ [y].B #})` by auto } moreover {assume "c = ({#T \ [y].B #} \* {#})" then have "{#F \ [x].A #} \ H" using `c = (G \* H)` by auto } ultimately have "{# F \ [x].A #} \ H" by blast } ultimately show ?thesis using `r \ R1 \ r \ R2 \ r \ R3` by blast qed moreover have "succ S + succ (snd r) = (\ \ F \ [x].A)" using ext and extendRule_def[where forms=S and R=r] and extend_def[where forms=S and seq="snd r"] by auto then have "\ + H = \ \ F \ [x].A" using `S = (\ \* \)` and `r = (ps,c)` and `c = (G \* H)` by auto moreover from `r = (ps,c)` and `r \ R1 \ r \ R2 \ r \ R3` and `R1 \ propRules` and `R2 \ nprovRules` and `R3 \ provRules` have "(ps,c) \ propRules \ (ps,c) \ nprovRules \ (ps,c) \ provRules" by auto then have "\ A. c = ({#} \* {#A#}) \ c = ({#A#} \* {#})" using propRuleCharacterise[where Ps=ps and C=c] and nprovRuleCharacterise[where Ps=ps and C=c] and provRuleCharacterise[where Ps=ps and C=c] by auto then have "H = {#} \ (\ A. H = {#A#})" using `c = (G \* H)` by auto ultimately have "F \ [x].A :# \" proof- have "H = {#} \ (\ A. H = {#A#})" by fact moreover {assume "H = {#}" then have "\ = \ \ F \ [x].A" using `\ + H = \ \ F \ [x].A` by auto then have "F \ [x].A :# \" by auto } moreover {assume "\ A. H = {#A#}" then obtain T where "H = {#T#}" by auto then have "\ \ T = \ \ F \ [x].A" using `\ + H = \ \ F \ [x].A` by auto then have "set_of (\ \ T) = set_of (\ \ F \ [x].A)" by auto then have "set_of \ \ {T} = set_of \ \ {F \ [x].A}" by auto moreover from `H = {#T#}` and `{#F \ [x].A#} \ H` have "F \ [x].A \ T" by auto ultimately have "F \ [x].A \ set_of \" by auto then have "F \ [x].A :# \" by auto } ultimately show "F \ [x].A :# \" by blast qed then have "\ \1. \ = \1 \ F \ [x].A" by (rule_tac x="\ \ F \ [x].A" in exI) (auto simp add:multiset_eq_conv_count_eq) then obtain \1 where "S = (\ \* \1 \ F \ [x].A)" using `S = (\ \* \)` by auto have "Ps = map (extend S) ps" using `extendRule S r = (Ps,\ \* \ \ F \ [x].A)` and extendRule_def and `r = (ps,c)` by auto then have "\ p \ set Ps. (\ p'. p = extend S p')" using ex_map_conv[where ys=Ps and f="extend S"] by auto then have "\ p \ set Ps. (F \ [x].A :# succ p)" using `F \ [x].A :# \` and `S = (\ \* \)` apply (auto simp add:Ball_def) by (drule_tac x=xa in spec) (auto simp add:extend_def) then have a1:"\ p \ set Ps. \ \' \'. p = (\' \* \' \ F \ [x].A)" using characteriseSeq apply (auto simp add:Ball_def) apply (drule_tac x=xa in spec,simp) apply (rule_tac x="antec xa" in exI,rule_tac x="succ xa \ F \ [x].A" in exI) by (drule_tac x=xa in meta_spec) (auto simp add:multiset_eq_conv_count_eq) with all have "\ p \ set Ps. \ \' \' n. n\n' \ (\' \* \' \ F \ [x].A,n) \ derivable R* \ p = (\' \* \' \ F \ [x].A)" by (auto simp add:Ball_def) then have a2: "\ p \ set Ps. \ \' \' m. m\n' \ (\' + \' \* \' + \',m) \ derivable R* \ p = (\' \* \' \ F \ [x].A)" using num and b' and IH and c' apply (auto simp add:Ball_def) apply (drule_tac x=xa in spec) apply simp apply (elim exE conjE) apply (drule_tac x=n in spec) apply simp apply (drule_tac x=\' in spec,drule_tac x=\' in spec) apply (simp) apply (elim exE conjE) by (rule_tac x=m' in exI) (arith) obtain Ps' where eq: "Ps' = map (extend (\ + \' \* \1 + \')) ps" by auto have "length Ps = length Ps'" using `Ps' = map (extend (\ + \' \* \1 + \')) ps` and `Ps = map (extend S) ps` by auto then have "Ps' \ []" using nonempty by auto from `r \ R1 \ r \ R2 \ r \ R3` have "r \ R" using `R = idRules \ R1 \ R2 \ R3` by auto then have "extendRule (\ + \' \* \1 + \') r \ R*" using `R = idRules \ R1 \ R2 \ R3` and extend_for_any_seq[where ?R1.0=R1 and ?R2.0=R2 and ?R3.0=R3 and R=R and r=r and S="\ + \' \* \1 + \'"] and `R1 \ propRules` and `R2 \ nprovRules` and `R3 \ provRules` by auto moreover have "extendRule (\ + \' \* \1 + \') r = (Ps',\ + \' \* \ + \')" using `S = (\ \* \1 \ F \ [x].A)` and `extendRule S r = (Ps, \ \* \ \ F \ [x].A)` and `r = (ps,c)` and eq by (auto simp add:extendRule_def extend_def union_ac multiset_eq_conv_count_eq) ultimately have "(Ps',\ + \' \* \ + \') \ R*" by simp have c1:"\ p \ set ps. extend S p \ set Ps" using `Ps = map (extend S) ps` by (simp add:Ball_def) have c2:"\ p \ set ps. extend (\ + \' \* \1 + \') p \ set Ps'" using eq by (simp add:Ball_def) then have eq2:"\ p \ set Ps'. \ \' \'. p = (\' + \' \* \' + \')" using eq apply (auto simp add:Ball_def extend_def) apply (drule_tac x=xa in spec,simp) apply (rule_tac x="\ + antec xa" in exI) apply (simp add:union_ac) apply (drule_tac x=xa in spec,simp) by (rule_tac x="\1 + succ xa" in exI) (simp add: union_ac) have d1:"\ p \ set Ps. \ p' \ set ps. p = extend S p'" using `Ps = map (extend S) ps` by (auto simp add:Ball_def Bex_def) then have "\ p \ set Ps. \ p'. p' \ set Ps'" using c2 by (auto simp add:Ball_def Bex_def) moreover have d2: "\ p \ set Ps'. \ p' \ set ps. p = extend (\ + \' \* \1 + \') p'" using eq by (auto simp add:Ball_def Bex_def) then have "\ p \ set Ps'. \ p'. p' \ set Ps" using c1 by (auto simp add:Ball_def Bex_def) have "\ \' \'. (\' \* \' \ F \ [x].A) \ set Ps \ (\' + \' \* \' + \') \ set Ps'" proof- {fix \' \' assume "(\' \* \' \ F \ [x].A) \ set Ps" then have "\ p \ set ps. extend (\ \* \1 \ F \ [x].A) p = (\' \* \' \ F \ [x].A)" using `Ps = map (extend S) ps` and `S = (\ \* \1 \ F \ [x].A)` and a1 and d1 apply (simp only:Ball_def Bex_def) apply (drule_tac x=" \' \* \' \ F \ [x].A" in spec) by (drule_tac x="\' \* \' \ F \ [x].A" in spec) (auto) then obtain p where t:"p \ set ps \ (\' \* \' \ F \ [x].A) = extend (\ \* \1 \ F \ [x].A) p" apply auto by (drule_tac x=p in meta_spec) (simp) then obtain D B where "p = (D \* B)" by (cases p) then have "(D \* B) \ set ps \ (\' \* \' \ F \ [x].A) = extend (\ \* \1 \ F \ [x].A) (D \* B)" using t by auto then have ant: "\' = \ + D" and suc: "\' \ F \ [x].A = \1 \ F \ [x].A + B" using extend_def by auto from ant have "\' + \' = (\ + \') + D" by (auto simp add:union_ac) moreover from suc have "\' = \1 + B" by (auto simp add:union_ac multiset_eq_conv_count_eq) then have "\' + \' = (\1 + \') + B" by (auto simp add:union_ac) ultimately have "(\' + \' \* \' + \') = extend (\ + \' \* \1 + \') (D \* B)" using extend_def by auto moreover have "extend (\ + \' \* \1 + \') (D \* B) \ set Ps'" using `p = (D \* B)` and t and c2 by auto ultimately have "(\' + \' \* \' + \') \ set Ps'" by simp } thus ?thesis by blast qed moreover have "\ \' \'. (\' + \' \* \' + \') \ set Ps' \ (\' \* \' \ F \ [x].A) \ set Ps" proof- {fix \' \' assume "(\' + \' \* \' + \') \ set Ps'" then have "\ p \ set ps. extend (\ + \' \* \1 + \') p = (\' + \' \* \' + \')" using eq and eq2 and d2 apply (simp only:Ball_def Bex_def) apply (drule_tac x="\' + \' \* \' + \'" in spec) by (drule_tac x="\' + \' \* \' + \'" in spec) (auto) then obtain p where t:"p \ set ps \ (\' + \' \* \' + \') = extend (\ + \' \* \1 + \') p" apply auto by (drule_tac x=p in meta_spec) (simp) then obtain D B where "p = (D \* B)" by (cases p) then have "(D \* B) \ set ps \ (\' + \' \* \' + \') = extend (\ + \' \* \1 + \') (D \* B)" using t by auto then have ant: "\' + \' = \ + \' + D" and suc: "\' + \' = \1 + \' + B" using extend_def by auto from ant have "\' + \' = (\ + D) + \'" by (auto simp add:union_ac) then have "\' = \ + D" by simp moreover from suc have "\' + \' = (\1 + B) + \'" by (auto simp add:union_ac) then have "\' = \1 + B" by simp then have "\' \ F \ [x].A = (\1 \ F \ [x].A) + B" by (auto simp add:union_ac) ultimately have "(\' \* \' \ F \ [x].A) = extend (\ \* \1 \ F \ [x].A) (D \* B)" using extend_def by auto moreover have "extend (\ \* \1 \ F \ [x].A) (D \* B) \ set Ps" using `p = (D \* B)` and t and c1 and `S = (\ \* \1 \ F \ [x].A)` by auto ultimately have "(\' \* \' \ F \ [x].A) \ set Ps" by simp } thus ?thesis by blast qed ultimately have "\ \' \'. ((\' \* \' \ F \ [x].A) \ set Ps) = ((\' + \' \* \' + \') \ set Ps')" by auto then have "\ p \ set Ps'. \ \' \' n. n\n' \ (\' + \' \* \' + \',n) \ derivable R* \ p = (\' + \' \* \' + \')" using eq2 and a2 apply (simp add:Ball_def) apply (intro allI impI) apply (drule_tac x=xa in spec) apply simp apply (elim exE) apply (drule_tac x=\' in spec,drule_tac x=\' in spec) by (drule_tac x="\' \* \' \ F \ [x].A" in spec) (simp) then have all:"\ p \ set Ps'. \ n\n'. (p,n) \ derivable R*" by auto then show "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" using num and `(Ps',\ + \' \* \ + \') \ R*` and `Ps' \ []` and derivable.step[where r="(Ps',\ + \' \* \ + \')" and R="R*"] by (auto simp add:Ball_def Bex_def) qed (* Non-principal Left *) lemma nonPrincipalInvertLeft: assumes "R1 \ propRules" and "R2 \ nprovRules" and "R3 \ provRules" and "R = idRules \ R1 \ R2 \ R3" and "r \ R1 \ r \ R2 \ r \ R3" and "r = (ps,c)" and IH: "\m\ \. ( \ \ F \ [x].A \* \, m) \ derivable R* \ (\r' \ R. leftPrincipal r' (F \ [x].A) \ ( \' \* \') \ set (fst r')) \ (\ multSubst \' \ \ multSubst \') \ (\m'\m. ( \ + \' \* \ + \', m') \ derivable R*)" and a': "(\ \ F \ [x].A \* \,n) \ derivable R*" and b': "\ r' \ R. leftPrincipal r' (F \ [x].A) \ (\' \* \') \ set (fst r')" and c': "\ multSubst \' \ \ multSubst \'" and np: "\ leftPrincipal r (F \ [x].A)" and ext: "extendRule S r = (Ps,\ \ F \ [x].A \* \)" and num: "n = n' + 1" and all: "\ p \ set Ps. \ n\n'. (p,n) \ derivable R*" and nonempty: "Ps \ []" shows "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" proof- from ext obtain \ \ where "S = (\ \* \)" by (cases S) (auto) from `r = (ps,c)` obtain G H where "c = (G \* H)" by (cases c) (auto) then have "{# F \ [x].A #} \ G" using `r \ R1 \ r \ R2 \ r \ R3` proof- {assume "r \ R1" then have "r \ propRules" using `R1 \ propRules` by auto with `r = (ps,c)` obtain T Ts where "c = ({#} \* {#Cpd0 T Ts#}) \ c = ({#Cpd0 T Ts#} \* {#})" using propRuleCharacterise[where Ps=ps and C=c] by auto moreover {assume "c = ({#} \* {#Cpd0 T Ts#})" with `c = (G \* H)` have "{# F \ [x].A #} \ G" by auto } moreover {assume "c = ({#Cpd0 T Ts#} \* {#})" then have "{#F \ [x].A #} \ G" using `c = (G \* H)` by auto } ultimately have "{# F \ [x].A #} \ G" by blast } moreover {assume "r \ R2 \ r \ R3" then have "r \ provRules \ r \ nprovRules" using `R2 \ nprovRules` and `R3 \ provRules` by auto with `r = (ps,c)` obtain T y B where "c = ({#} \* {# T \ [y].B #}) \ c = ({# T \ [y].B#} \* {#})" using provRuleCharacterise[where Ps=ps and C=c] and nprovRuleCharacterise[where Ps=ps and C=c] by auto moreover {assume "c = ({#} \* {# T \ [y].B#})" then have "{#F \ [x].A #} \ G" using `c = (G \* H)` by auto } moreover {assume "c = ({#T \ [y].B #} \* {#})" then have "leftPrincipal r (T \ [y].B)" using `r = (ps,c)` by auto with `\ leftPrincipal r (F \ [x].A)` have "T \ [y].B \ F \ [x].A" by auto with `c = (G \* H)` have "{# F \ [x].A #} \ G" using `c = ({# T \ [y].B #} \* {#})` by auto } ultimately have "{# F \ [x].A #} \ G" by blast } ultimately show ?thesis using `r \ R1 \ r \ R2 \ r \ R3` by blast qed moreover have "antec S + antec (snd r) = (\ \ F \ [x].A)" using ext and extendRule_def[where forms=S and R=r] and extend_def[where forms=S and seq="snd r"] by auto then have "\ + G = \ \ F \ [x].A" using `S = (\ \* \)` and `r = (ps,c)` and `c = (G \* H)` by auto moreover from `r = (ps,c)` and `r \ R1 \ r \ R2 \ r \ R3` and `R1 \ propRules` and `R2 \ nprovRules` and `R3 \ provRules` have "(ps,c) \ propRules \ (ps,c) \ nprovRules \ (ps,c) \ provRules" by auto then have "\ A. c = ({#} \* {#A#}) \ c = ({#A#} \* {#})" using propRuleCharacterise[where Ps=ps and C=c] and nprovRuleCharacterise[where Ps=ps and C=c] and provRuleCharacterise[where Ps=ps and C=c] by auto then have "G = {#} \ (\ A. G = {#A#})" using `c = (G \* H)` by auto ultimately have "F \ [x].A :# \" proof- have "G = {#} \ (\ A. G = {#A#})" by fact moreover {assume "G = {#}" then have "\ = \ \ F \ [x].A" using `\ + G = \ \ F \ [x].A` by auto then have "F \ [x].A :# \" by auto } moreover {assume "\ A. G = {#A#}" then obtain T where "G = {#T#}" by auto then have "\ \ T = \ \ F \ [x].A" using `\ + G = \ \ F \ [x].A` by auto then have "set_of (\ \ T) = set_of (\ \ F \ [x].A)" by auto then have "set_of \ \ {T} = set_of \ \ {F \ [x].A}" by auto moreover from `G = {#T#}` and `{#F \ [x].A#} \ G` have "F \ [x].A \ T" by auto ultimately have "F \ [x].A \ set_of \" by auto then have "F \ [x].A :# \" by auto } ultimately show "F \ [x].A :# \" by blast qed then have "\ \1. \ = \1 \ F \ [x].A" by (rule_tac x="\ \ F \ [x].A" in exI) (auto simp add:multiset_eq_conv_count_eq) then obtain \1 where "S = (\1 \ F \ [x].A \* \)" using `S = (\ \* \)` by auto have "Ps = map (extend S) ps" using `extendRule S r = (Ps,\ \ F \ [x].A \* \)` and extendRule_def and `r = (ps,c)` by auto then have "\ p \ set Ps. (\ p'. p = extend S p')" using ex_map_conv[where ys=Ps and f="extend S"] by auto then have "\ p \ set Ps. (F \ [x].A :# antec p)" using `F \ [x].A :# \` and `S = (\ \* \)` apply (auto simp add:Ball_def) by (drule_tac x=xa in spec) (auto simp add:extend_def) then have a1:"\ p \ set Ps. \ \' \'. p = (\' \ F \ [x].A \* \')" using characteriseSeq apply (auto simp add:Ball_def) apply (drule_tac x=xa in spec,simp) apply (rule_tac x="antec xa \ F \ [x].A" in exI,rule_tac x="succ xa" in exI) by (drule_tac x=xa in meta_spec) (auto simp add:multiset_eq_conv_count_eq) with all have "\ p \ set Ps. \ \' \' n. n\n' \ (\' \ F \ [x].A \* \',n) \ derivable R* \ p = (\' \ F \ [x].A \* \')" by (auto simp add:Ball_def) then have a2: "\ p \ set Ps. \ \' \' m. m\n' \ (\' + \' \* \' + \',m) \ derivable R* \ p = (\' \ F \ [x].A \* \')" using num and b' and IH and c' apply (auto simp add:Ball_def) apply (drule_tac x=xa in spec) apply simp apply (elim exE conjE) apply (drule_tac x=n in spec) apply simp apply (drule_tac x=\' in spec,drule_tac x=\' in spec) apply (simp) apply (elim exE conjE) by (rule_tac x=m' in exI) (arith) obtain Ps' where eq: "Ps' = map (extend (\1 + \' \* \ + \')) ps" by auto have "length Ps = length Ps'" using `Ps' = map (extend (\1 + \' \* \ + \')) ps` and `Ps = map (extend S) ps` by auto then have "Ps' \ []" using nonempty by auto from `r \ R1 \ r \ R2 \ r \ R3` have "r \ R" using `R = idRules \ R1 \ R2 \ R3` by auto then have "extendRule (\1 + \' \* \ + \') r \ R*" using `R = idRules \ R1 \ R2 \ R3` and extend_for_any_seq[where ?R1.0=R1 and ?R2.0=R2 and ?R3.0=R3 and R=R and r=r and S="\1 + \' \* \ + \'"] and `R1 \ propRules` and `R2 \ nprovRules` and `R3 \ provRules` by auto moreover have "extendRule (\1 + \' \* \ + \') r = (Ps',\ + \' \* \ + \')" using `S = (\1 \ F \ [x].A \* \)` and `extendRule S r = (Ps, \ \ F \ [x].A \* \)` and `r = (ps,c)` and eq by (auto simp add:extendRule_def extend_def union_ac multiset_eq_conv_count_eq) ultimately have "(Ps',\ + \' \* \ + \') \ R*" by simp have c1:"\ p \ set ps. extend S p \ set Ps" using `Ps = map (extend S) ps` by (simp add:Ball_def) have c2:"\ p \ set ps. extend (\1 + \' \* \ + \') p \ set Ps'" using eq by (simp add:Ball_def) then have eq2:"\ p \ set Ps'. \ \' \'. p = (\' + \' \* \' + \')" using eq apply (auto simp add:Ball_def extend_def) apply (drule_tac x=xa in spec,simp) apply (rule_tac x="\1 + antec xa" in exI) apply (simp add:union_ac) apply (drule_tac x=xa in spec,simp) by (rule_tac x="\ + succ xa" in exI) (simp add: union_ac) have d1:"\ p \ set Ps. \ p' \ set ps. p = extend S p'" using `Ps = map (extend S) ps` by (auto simp add:Ball_def Bex_def) then have "\ p \ set Ps. \ p'. p' \ set Ps'" using c2 by (auto simp add:Ball_def Bex_def) moreover have d2: "\ p \ set Ps'. \ p' \ set ps. p = extend (\1 + \' \* \ + \') p'" using eq by (auto simp add:Ball_def Bex_def) then have "\ p \ set Ps'. \ p'. p' \ set Ps" using c1 by (auto simp add:Ball_def Bex_def) have "\ \' \'. (\' \ F \ [x].A \* \') \ set Ps \ (\' + \' \* \' + \') \ set Ps'" proof- {fix \' \' assume "(\' \ F \ [x].A \* \') \ set Ps" then have "\ p \ set ps. extend (\1 \ F \ [x].A \* \) p = (\' \ F \ [x].A \* \')" using `Ps = map (extend S) ps` and `S = (\1 \ F \ [x].A \* \)` and a1 and d1 apply (simp only:Ball_def Bex_def) apply (drule_tac x=" \' \ F \ [x].A \* \'" in spec) by (drule_tac x="\' \ F \ [x].A \* \'" in spec) (auto) then obtain p where t:"p \ set ps \ (\' \ F \ [x].A \* \') = extend (\1 \ F \ [x].A \* \) p" apply auto by (drule_tac x=p in meta_spec) (simp) then obtain D B where "p = (D \* B)" by (cases p) then have "(D \* B) \ set ps \ (\' \ F \ [x].A \* \') = extend (\1 \ F \ [x].A \* \) (D \* B)" using t by auto then have ant: "\' \ F \ [x].A = \1 \ F \ [x].A + D" and suc: "\' = \ + B" using extend_def by auto from suc have "\' + \' = (\ + \') + B" by (auto simp add:union_ac) moreover from ant have "\' = \1 + D" by (auto simp add:union_ac multiset_eq_conv_count_eq) then have "\' + \' = (\1 + \') + D" by (auto simp add:union_ac) ultimately have "(\' + \' \* \' + \') = extend (\1 + \' \* \ + \') (D \* B)" using extend_def by auto moreover have "extend (\1 + \' \* \ + \') (D \* B) \ set Ps'" using `p = (D \* B)` and t and c2 by auto ultimately have "(\' + \' \* \' + \') \ set Ps'" by simp } thus ?thesis by blast qed moreover have "\ \' \'. (\' + \' \* \' + \') \ set Ps' \ (\' \ F \ [x].A \* \') \ set Ps" proof- {fix \' \' assume "(\' + \' \* \' + \') \ set Ps'" then have "\ p \ set ps. extend (\1 + \' \* \ + \') p = (\' + \' \* \' + \')" using eq and eq2 and d2 apply (simp only:Ball_def Bex_def) apply (drule_tac x="\' + \' \* \' + \'" in spec) by (drule_tac x="\' + \' \* \' + \'" in spec) (auto) then obtain p where t:"p \ set ps \ (\' + \' \* \' + \') = extend (\1 + \' \* \ + \') p" apply auto by (drule_tac x=p in meta_spec) (simp) then obtain D B where "p = (D \* B)" by (cases p) then have "(D \* B) \ set ps \ (\' + \' \* \' + \') = extend (\1 + \' \* \ + \') (D \* B)" using t by auto then have ant: "\' + \' = \1 + \' + D" and suc: "\' + \' = \ + \' + B" using extend_def by auto from ant have "\' + \' = (\1 + D) + \'" by (auto simp add:union_ac) then have "\' = \1 + D" by simp then have "\' \ F \ [x].A = (\1 \ F \ [x].A) + D" by (auto simp add:union_ac) moreover from suc have "\' + \' = (\ + B) + \'" by (auto simp add:union_ac) then have "\' = \ + B" by simp ultimately have "(\' \ F \ [x].A \* \') = extend (\1 \ F \ [x].A \* \) (D \* B)" using extend_def by auto moreover have "extend (\1 \ F \ [x].A \* \) (D \* B) \ set Ps" using `p = (D \* B)` and t and c1 and `S = (\1 \ F \ [x].A \* \)` by auto ultimately have "(\' \ F \ [x].A \* \') \ set Ps" by simp } thus ?thesis by blast qed ultimately have "\ \' \'. ((\' \ F \ [x].A \* \') \ set Ps) = ((\' + \' \* \' + \') \ set Ps')" by auto then have "\ p \ set Ps'. \ \' \' n. n\n' \ (\' + \' \* \' + \',n) \ derivable R* \ p = (\' + \' \* \' + \')" using eq2 and a2 apply (simp add:Ball_def) apply (intro allI impI) apply (drule_tac x=xa in spec) apply simp apply (elim exE) apply (drule_tac x=\' in spec,drule_tac x=\' in spec) by (drule_tac x="\' \ F \ [x].A \* \'" in spec) (simp) then have all:"\ p \ set Ps'. \ n\n'. (p,n) \ derivable R*" by auto then show "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" using num and `(Ps',\ + \' \* \ + \') \ R*` and `Ps' \ []` and derivable.step[where r="(Ps',\ + \' \* \ + \')" and R="R*"] by (auto simp add:Ball_def Bex_def) qed lemma rightInvert: fixes \ \ :: "form multiset" assumes rules: "R1 \ propRules \ R2 \ nprovRules \ R3 \ provRules \ R = idRules \ R1 \ R2 \ R3" and a: "(\ \* \ \ F \ [x].A,n) \ derivable R*" and b: "\ r' \ R. rightPrincipal r' (F \ [x].A) \ (\' \* \') \ set (fst r')" and c: "\ multSubst \' \ \ multSubst \'" shows "\ m\n. (\ +\' \* \ + \',m) \ derivable R*" using assms proof (induct n arbitrary: \ \ rule:nat_less_induct) case (1 n \ \) then have IH:"\m\ \. ( \ \* \ \ F \ [x].A, m) \ derivable R* \ (\r' \ R. rightPrincipal r' (F \ [x].A) \ ( \' \* \') \ set (fst r')) \ (\ multSubst \' \ \ multSubst \') \ (\m'\m. ( \ + \' \* \ + \', m') \ derivable R*)" and a': "(\ \* \ \ F \ [x].A,n) \ derivable R*" and b': "\ r' \ R. rightPrincipal r' (F \ [x].A) \ (\' \* \') \ set (fst r')" and c': "\ multSubst \' \ \ multSubst \'" by auto show ?case proof (cases n) case 0 then have "(\ \* \ \ F \ [x].A,0) \ derivable R*" using a' by simp then have "([],\ \* \ \ F \ [x].A) \ R*" by (cases) (auto) then have "\ r S. extendRule S r = ([],\ \* \ \ F \ [x].A) \ (r \ idRules \ r \ R1 \ r \ R2 \ r \ R3)" using rules and ruleSet[where ?R1.0=R1 and ?R2.0=R2 and ?R3.0=R3 and R=R and Ps="[]" and C="\ \* \ \ F \ [x].A"] by auto then obtain r S where "extendRule S r = ([],\ \* \ \ F \ [x].A)" and "r \ idRules \ r \ R1 \ r \ R2 \ r \ R3" by auto moreover {assume "r \ idRules" then have "\ i xs. r = ([],{# At i xs #} \* {# At i xs #})" using characteriseID[where r=r] by auto then obtain i xs where "([], {# At i xs #} \* {# At i xs #}) = r" by blast from `extendRule S r = ([],\ \* \ \ F \ [x].A)` and `([], {# At i xs #} \* {# At i xs #}) = r` have "extend S ({# At i xs #} \* {# At i xs #}) = (\ \* \ \ F \ [x].A)" using extendRule_def[where R=r and forms=S] extend_def[where forms=S and seq="{#At i xs#} \* {#At i xs#}"] by auto then have "At i xs :# \ \ At i xs :# \" using extendID[where S=S and i=i and xs=xs and \=\ and \="\ \ F \ [x].A"] by auto then have "At i xs :# \ + \' \ At i xs :# \ + \'" by auto then have "(\ + \' \* \ + \',0) \ derivable R*" using rules and containID[where \="\ + \'" and i=i and \="\ + \'" and R=R] by auto } moreover {assume "r \ R1 \ r \ R2 \ r \ R3" then have "\ Ps C. Ps \ [] \ r = (Ps,C)" proof- obtain y z where "r = (y,z)" by (cases r) with `r \ R1 \ r \ R2 \ r \ R3` have "(y,z) \ R1 \ (y,z) \ R2 \ (y,z) \ R3" by simp then have "y \ []" proof- {assume "(y,z) \ R1" then have "(y,z) \ propRules" using rules by auto then have "y\[]" by (cases) auto } moreover {assume "(y,z) \ R2" then have "(y,z) \ nprovRules" using rules by auto then have "y\[]" by (cases) auto } moreover {assume "(y,z) \ R3" then have "(y,z) \ provRules" using rules by auto then have "y\[]" by (cases) auto } ultimately show "y \ []" using `(y,z) \ R1 \ (y,z) \ R2 \ (y,z) \ R3` by blast qed then show "\ Ps C. Ps \ [] \ r = (Ps,C)" using `r = (y,z)` by blast qed then obtain Ps C where "Ps \ []" and "r = (Ps,C)" by auto moreover from `extendRule S r = ([], \ \* \ \ F \ [x].A)` have "\ S. r = ([],S)" using extendRule_def[where forms=S and R=r] by (cases r) (auto) then obtain S where "r = ([],S)" by blast ultimately have "(\ + \' \* \ + \',0) \ derivable R*" using rules by simp } ultimately show "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" using `n=0` by blast next case (Suc n') then have "(\ \* \ \ F \ [x].A,n'+1) \ derivable R*" using a' by simp then obtain Ps where "(Ps, \ \* \ \ F \ [x].A) \ R*" and "Ps \ []" and d':"\ p \ set Ps. \ n\n'. (p,n) \ derivable R*" using characteriseLast[where C="\ \* \ \ F \ [x].A" and m=n' and R="R*"] by auto then have "\ r S. (r \ idRules \ r \ R1 \ r \ R2 \ r \ R3) \ extendRule S r = (Ps, \ \* \ \ F \ [x].A)" using rules and ruleSet[where ?R1.0=R1 and ?R2.0=R2 and ?R3.0=R3 and R=R and Ps=Ps and C="\ \* \ \ F \ [x].A"] by auto then obtain r S where "r \ idRules \ r \ R1 \ r \ R2 \ r \ R3" and e':"extendRule S r = (Ps, \ \* \ \ F \ [x].A)" by auto moreover {assume "r \ idRules" then have "\ i xs. r = ([],{# At i xs #} \* {# At i xs #})" using characteriseID[where r=r] by auto moreover obtain z y where "r = (z,y)" by (cases r) then have "z \ []" using `Ps \ []` and `extendRule S r = (Ps, \ \* \ \ F \ [x].A)` and extendRule_def[where forms=S and R=r] and extend_def[where forms=S and seq="snd r"] by auto ultimately have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" using `r=(z,y)` by auto } moreover {assume "r \ R1" obtain ps c where "r = (ps,c)" by (cases r) auto then have "r \ propRules" using rules and `r \ R1` by auto then obtain T Ts where sw:"c = ({#} \* {# Cpd0 T Ts #}) \ c = ({# Cpd0 T Ts #} \* {#})" using propRuleCharacterise[where Ps=ps and C=c] and `r = (ps,c)` by auto have "(rightPrincipal r (F \ [x].A)) \ \(rightPrincipal r (F \ [x].A))" by blast moreover {assume "rightPrincipal r (F \ [x].A)" then have "c = ({#} \* {# F \ [x].A #})" using `r= (ps,c)` by (cases) auto with sw have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" by auto } moreover {assume "\ rightPrincipal r (F \ [x].A)" then have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" using nonPrincipalInvertRight[where r=r and F=F and x=x and A=A and ps=ps and c=c and R=R and \'=\' and \'=\' and ?R1.0=R1 and ?R2.0=R2 and ?R3.0=R3 and S=S and Ps=Ps and \=\ and \=\ and n=n and n'=n'] and `n = Suc n'` and `Ps \ []` and a' and b' and e' and c' and rules and IH and `r \ R1` and d' and `r = (ps,c)` by auto } ultimately have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" by blast } moreover {assume "r \ R2" obtain ps c where "r = (ps,c)" by (cases r) auto then have "r \ nprovRules" using rules and `r \ R2` by auto have "rightPrincipal r (F \ [x].A) \ \ rightPrincipal r (F \ [x].A)" by blast moreover {assume "rightPrincipal r (F \ [x].A)" then have "(\' \* \') \ set ps" using b' and `r = (ps,c)` and `r \ R2` and rules by auto then have "extend S (\' \* \') \ set Ps" using `extendRule S r = (Ps,\ \* \ \ F \ [x].A)` and `r = (ps,c)` by (simp add:extendContain) moreover from `rightPrincipal r (F \ [x].A)` have "c = ({#} \* {#F \ [x].A#})" using `r = (ps,c)` by (cases) auto with `extendRule S r = (Ps,\ \* \ \ F \ [x].A)` have "S = (\ \* \)" using `r = (ps,c)` apply (auto simp add:extendRule_def extend_def) by (cases S) auto ultimately have "(\ + \' \* \ + \') \ set Ps" by (simp add:extend_def) then have "\ m\n'. (\ + \' \* \ + \',m) \ derivable R*" using `\ p \ set Ps. \ n\n'. (p,n) \ derivable R*` by auto then have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" using `n = Suc n'` by (auto,rule_tac x=m in exI) (simp) } moreover {assume "\ rightPrincipal r (F \ [x].A)" then have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" using nonPrincipalInvertRight[where r=r and F=F and x=x and A=A and ps=ps and c=c and R=R and \'=\' and \'=\' and ?R1.0=R1 and ?R2.0=R2 and ?R3.0=R3 and S=S and Ps=Ps and \=\ and \=\ and n=n and n'=n'] and `n = Suc n'` and `Ps \ []` and a' and b' and e' and c' and rules and IH and `r \ R2` and d' and `r = (ps,c)` by auto } ultimately have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" by blast } moreover {assume "r \ R3" obtain ps c where "r = (ps,c)" by (cases r) auto then have "r \ provRules" using rules and `r \ R3` by auto have "rightPrincipal r (F \ [x].A) \ \ rightPrincipal r (F \ [x].A)" by blast moreover {assume "rightPrincipal r (F \ [x].A)" then have "(\' \* \') \ set ps" using b' and `r = (ps,c)` and `r \ R3` and rules by auto then have "extend S (\' \* \') \ set Ps" using `extendRule S r = (Ps,\ \* \ \ F \ [x].A)` and `r = (ps,c)` by (simp add:extendContain) moreover from `rightPrincipal r (F \ [x].A)` have "c = ({#} \* {#F \ [x].A#})" using `r = (ps,c)` by (cases) auto with `extendRule S r = (Ps,\ \* \ \ F \ [x].A)` have "S = (\ \* \)" using `r = (ps,c)` apply (auto simp add:extendRule_def extend_def) by (cases S) auto ultimately have "(\ + \' \* \ + \') \ set Ps" by (simp add:extend_def) then have "\ m\n'. (\ + \' \* \ + \',m) \ derivable R*" using `\ p \ set Ps. \ n\n'. (p,n) \ derivable R*` by auto then have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" using `n = Suc n'` by (auto,rule_tac x=m in exI) (simp) } moreover {assume "\ rightPrincipal r (F \ [x].A)" then have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" using nonPrincipalInvertRight[where r=r and F=F and x=x and A=A and ps=ps and c=c and R=R and \'=\' and \'=\' and ?R1.0=R1 and ?R2.0=R2 and ?R3.0=R3 and S=S and Ps=Ps and \=\ and \=\ and n=n and n'=n'] and `n = Suc n'` and `Ps \ []` and a' and b' and e' and c' and rules and IH and `r \ R3` and d' and `r = (ps,c)` by auto } ultimately have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" by blast } ultimately show "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" by blast qed qed lemma leftInvert: fixes \ \ :: "form multiset" assumes rules: "R1 \ propRules \ R2 \ nprovRules \ R3 \ provRules \ R = idRules \ R1 \ R2 \ R3" and a: "(\ \ F \ [x].A \* \,n) \ derivable R*" and b: "\ r' \ R. leftPrincipal r' (F \ [x].A) \ (\' \* \') \ set (fst r')" and c: "\ multSubst \' \ \ multSubst \'" shows "\ m\n. (\ +\' \* \ + \',m) \ derivable R*" using assms proof (induct n arbitrary: \ \ rule:nat_less_induct) case (1 n \ \) then have IH:"\m\ \. ( \ \ F \ [x].A \* \, m) \ derivable R* \ (\r' \ R. leftPrincipal r' (F \ [x].A) \ ( \' \* \') \ set (fst r')) \ (\ multSubst \' \ \ multSubst \') \ (\m'\m. ( \ + \' \* \ + \', m') \ derivable R*)" and a': "(\ \ F \ [x].A \* \,n) \ derivable R*" and b': "\ r' \ R. leftPrincipal r' (F \ [x].A) \ (\' \* \') \ set (fst r')" and c': "\ multSubst \' \ \ multSubst \'" by auto show ?case proof (cases n) case 0 then have "(\ \ F \ [x].A \* \,0) \ derivable R*" using a' by simp then have "([],\ \ F \ [x].A \* \) \ R*" by (cases) (auto) then have "\ r S. extendRule S r = ([],\ \ F \ [x].A \* \) \ (r \ idRules \ r \ R1 \ r \ R2 \ r \ R3)" using rules and ruleSet[where ?R1.0=R1 and ?R2.0=R2 and ?R3.0=R3 and R=R and Ps="[]" and C="\ \ F \ [x].A \*\"] by auto then obtain r S where "extendRule S r = ([],\ \ F \ [x].A \* \)" and "r \ idRules \ r \ R1 \ r \ R2 \ r \ R3" by auto moreover {assume "r \ idRules" then have "\ i xs. r = ([],{# At i xs #} \* {# At i xs #})" using characteriseID[where r=r] by auto then obtain i xs where "([], {# At i xs #} \* {# At i xs #}) = r" by blast from `extendRule S r = ([],\ \ F \ [x].A \* \)` and `([], {# At i xs #} \* {# At i xs #}) = r` have "extend S ({# At i xs #} \* {# At i xs #}) = (\ \ F \ [x].A \* \)" using extendRule_def[where R=r and forms=S] extend_def[where forms=S and seq="{#At i xs#} \* {#At i xs#}"] by auto then have "At i xs :# \ \ At i xs :# \" using extendID[where S=S and i=i and xs=xs and \="\\ F \ [x].A" and \=\] by auto then have "At i xs :# \ + \' \ At i xs :# \ + \'" by auto then have "(\ + \' \* \ + \',0) \ derivable R*" using rules and containID[where \="\ + \'" and i=i and \="\ + \'" and R=R] by auto } moreover {assume "r \ R1 \ r \ R2 \ r \ R3" then have "\ Ps C. Ps \ [] \ r = (Ps,C)" proof- obtain y z where "r = (y,z)" by (cases r) with `r \ R1 \ r \ R2 \ r \ R3` have "(y,z) \ R1 \ (y,z) \ R2 \ (y,z) \ R3" by simp then have "y \ []" proof- {assume "(y,z) \ R1" then have "(y,z) \ propRules" using rules by auto then have "y\[]" by (cases) auto } moreover {assume "(y,z) \ R2" then have "(y,z) \ nprovRules" using rules by auto then have "y\[]" by (cases) auto } moreover {assume "(y,z) \ R3" then have "(y,z) \ provRules" using rules by auto then have "y\[]" by (cases) auto } ultimately show "y \ []" using `(y,z) \ R1 \ (y,z) \ R2 \ (y,z) \ R3` by blast qed then show "\ Ps C. Ps \ [] \ r = (Ps,C)" using `r = (y,z)` by blast qed then obtain Ps C where "Ps \ []" and "r = (Ps,C)" by auto moreover from `extendRule S r = ([], \ \ F \ [x].A \* \)` have "\ S. r = ([],S)" using extendRule_def[where forms=S and R=r] by (cases r) (auto) then obtain S where "r = ([],S)" by blast ultimately have "(\ + \' \* \ + \',0) \ derivable R*" using rules by simp } ultimately show "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" using `n=0` by blast next case (Suc n') then have "(\ \ F \ [x].A \* \,n'+1) \ derivable R*" using a' by simp then obtain Ps where "(Ps, \ \ F \ [x].A \* \) \ R*" and "Ps \ []" and d':"\ p \ set Ps. \ n\n'. (p,n) \ derivable R*" using characteriseLast[where C="\ \ F \ [x].A \* \" and m=n' and R="R*"] by auto then have "\ r S. (r \ idRules \ r \ R1 \ r \ R2 \ r \ R3) \ extendRule S r = (Ps, \ \ F \ [x].A \* \)" using rules and ruleSet[where ?R1.0=R1 and ?R2.0=R2 and ?R3.0=R3 and R=R and Ps=Ps and C="\ \ F \ [x].A \* \"] by auto then obtain r S where "r \ idRules \ r \ R1 \ r \ R2 \ r \ R3" and e':"extendRule S r = (Ps, \ \ F \ [x].A \* \)" by auto moreover {assume "r \ idRules" then have "\ i xs. r = ([],{# At i xs #} \* {# At i xs #})" using characteriseID[where r=r] by auto moreover obtain z y where "r = (z,y)" by (cases r) then have "z \ []" using `Ps \ []` and `extendRule S r = (Ps, \ \ F \ [x].A \* \)` and extendRule_def[where forms=S and R=r] and extend_def[where forms=S and seq="snd r"] by auto ultimately have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" using `r=(z,y)` by auto } moreover {assume "r \ R1" obtain ps c where "r = (ps,c)" by (cases r) auto then have "r \ propRules" using rules and `r \ R1` by auto then obtain T Ts where sw:"c = ({#} \* {# Cpd0 T Ts #}) \ c = ({# Cpd0 T Ts #} \* {#})" using propRuleCharacterise[where Ps=ps and C=c] and `r = (ps,c)` by auto have "(leftPrincipal r (F \ [x].A)) \ \(leftPrincipal r (F \ [x].A))" by blast moreover {assume "leftPrincipal r (F \ [x].A)" then have "c = ({# F \ [x].A #} \* {#})" using `r= (ps,c)` by (cases) auto with sw have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" by auto } moreover {assume "\ leftPrincipal r (F \ [x].A)" then have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" using nonPrincipalInvertLeft[where r=r and F=F and x=x and A=A and ps=ps and c=c and R=R and \'=\' and \'=\' and ?R1.0=R1 and ?R2.0=R2 and ?R3.0=R3 and S=S and Ps=Ps and \=\ and \=\ and n=n and n'=n'] and `n = Suc n'` and `Ps \ []` and a' and b' and e' and c' and rules and IH and `r \ R1` and d' and `r = (ps,c)` by auto } ultimately have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" by blast } moreover {assume "r \ R2" obtain ps c where "r = (ps,c)" by (cases r) auto then have "r \ nprovRules" using rules and `r \ R2` by auto have "leftPrincipal r (F \ [x].A) \ \ leftPrincipal r (F \ [x].A)" by blast moreover {assume "leftPrincipal r (F \ [x].A)" then have "(\' \* \') \ set ps" using b' and `r = (ps,c)` and `r \ R2` and rules by auto then have "extend S (\' \* \') \ set Ps" using `extendRule S r = (Ps,\ \ F \ [x].A \* \)` and `r = (ps,c)` by (simp add:extendContain) moreover from `leftPrincipal r (F \ [x].A)` have "c = ({#F \ [x].A#} \* {#})" using `r = (ps,c)` by (cases) auto with `extendRule S r = (Ps,\ \ F \ [x].A \* \)` have "S = (\ \* \)" using `r = (ps,c)` apply (auto simp add:extendRule_def extend_def) by (cases S) auto ultimately have "(\ + \' \* \ + \') \ set Ps" by (simp add:extend_def) then have "\ m\n'. (\ + \' \* \ + \',m) \ derivable R*" using `\ p \ set Ps. \ n\n'. (p,n) \ derivable R*` by auto then have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" using `n = Suc n'` by (auto,rule_tac x=m in exI) (simp) } moreover {assume "\ leftPrincipal r (F \ [x].A)" then have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" using nonPrincipalInvertLeft[where r=r and F=F and x=x and A=A and ps=ps and c=c and R=R and \'=\' and \'=\' and ?R1.0=R1 and ?R2.0=R2 and ?R3.0=R3 and S=S and Ps=Ps and \=\ and \=\ and n=n and n'=n'] and `n = Suc n'` and `Ps \ []` and a' and b' and e' and c' and rules and IH and `r \ R2` and d' and `r = (ps,c)` by auto } ultimately have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" by blast } moreover {assume "r \ R3" obtain ps c where "r = (ps,c)" by (cases r) auto then have "r \ provRules" using rules and `r \ R3` by auto have "leftPrincipal r (F \ [x].A) \ \ leftPrincipal r (F \ [x].A)" by blast moreover {assume "leftPrincipal r (F \ [x].A)" then have "(\' \* \') \ set ps" using b' and `r = (ps,c)` and `r \ R3` and rules by auto then have "extend S (\' \* \') \ set Ps" using `extendRule S r = (Ps,\ \ F \ [x].A \* \)` and `r = (ps,c)` by (simp add:extendContain) moreover from `leftPrincipal r (F \ [x].A)` have "c = ({#F \ [x].A#} \* {#})" using `r = (ps,c)` by (cases) auto with `extendRule S r = (Ps,\ \ F \ [x].A\* \)` have "S = (\ \* \)" using `r = (ps,c)` apply (auto simp add:extendRule_def extend_def) by (cases S) auto ultimately have "(\ + \' \* \ + \') \ set Ps" by (simp add:extend_def) then have "\ m\n'. (\ + \' \* \ + \',m) \ derivable R*" using `\ p \ set Ps. \ n\n'. (p,n) \ derivable R*` by auto then have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" using `n = Suc n'` by (auto,rule_tac x=m in exI) (simp) } moreover {assume "\ leftPrincipal r (F \ [x].A)" then have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" using nonPrincipalInvertLeft[where r=r and F=F and x=x and A=A and ps=ps and c=c and R=R and \'=\' and \'=\' and ?R1.0=R1 and ?R2.0=R2 and ?R3.0=R3 and S=S and Ps=Ps and \=\ and \=\ and n=n and n'=n'] and `n = Suc n'` and `Ps \ []` and a' and b' and e' and c' and rules and IH and `r \ R3` and d' and `r = (ps,c)` by auto } ultimately have "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" by blast } ultimately show "\ m\n. (\ + \' \* \ + \',m) \ derivable R*" by blast qed qed end