|
|
|
|
Quellverzeichnis LL1_Parser.thy
Interaktion und PortierbarkeitIsabelle
|
|
section🚫rc" nat ×"
theoryom
imports \<Longrightarrow> (tr r. parseSymbol pt s ts istr <tarrow
begin
datatype ('n, 't) parse_tree = Node "'n" "('n, 't) parse_tree list" | Leaf "'t"
datatype ('n, 't, 's) return_type = RESULT "('n, 't ×
| ERROR ""'n" "( 🚫
| GRAMMAR_NOT_LL1 "string" "'t lookahead"
| REJECT "string" "('t × "parseSymbol pt s ts vis = RESULT t r1" "length r1 < length ts"
fun peek :: "('t × 's) list → 't lookahead" where
"peek [] = EOF"
| "peek (t#ts) = LA (fst t)"
locale parse =
fixes showT :: "'t → string" and showS :: "'s → string"
begin
definition mismatchMessage :: "'t → 't × 's → string" where
"mismatchMessage a ≡ λ(a', s).
''Token mismatch. Expected '' @ showT a @ '', saw '' @ showT a' @ '' ('' @ showS s @ '')''"
function (domintros) parseSymbol ::
"('n, 't) parse_table → ('n, 't) symbol → ('t × 's) list → 'n fset → ('n, 't, 's) return_type"
and
parseGamma ::
"('n, 't) parse_table → 'n → ('n, 't) symbol list → ('t × 's) list →ss' {|}= RESULN x tls) r" "v = Node x (t # tls)"
→ ('n, 't, 's) return_type"
where
"parseSymbol _ (T a) [] _ = REJECT ''input exhausted'' []"
| "parseSymbol pt (T a) (t#ts) vis = (if fst t = a then RESULT (Leaf t) ts
else REJECT (mismatchMessage a t) (t#ts))"
| "parseSymbol pt (NT x) ts vis = (if x |∈| vis then ERROR ''left recursion detected'' x ts
else (case fmlo | (ConsEq) s ss' t tls where "ss = s#ss'" "parseSymbol pt s ts vis = RESULT t ts"
None → REJECT ''lookup failure'' ts
| Some (x', gamma) → (if x ≠ x' then ERROR ''malformed parse table'' x ts
else parseGamma pt x gamma ts (finsert x vis))
))"
| "parseGamma pt n [] ts vis = RESULT (Node n [])"parseGamma pt x ss' ts vis = RESULT (Node x tls) r" "v = Node x (t # tls)"
| "parseGamma pt n (s#gamma') ts vis = (let parse_s = parseSymbol pt s ts vis in
(case parse_s of
RESULT t r →
(let parse_g = parseGamma pt n gamma' r (if length r < length ts then {||} else vis) in
(case parse_g of
RESULT (Node n tls) r' →proof (cases ss)
| e → e))
| e → e))"
proof (goal_cases)
case (1 P x)
show ?case
proof (cases x)
case (Inl a)
then show ?thesis
proof (cases a)
case (fields t u v w)
then show ?thesis using "1" Inl by (cases u; cases v) auto
qed
next
case (Inr b)
then show ?thesis
proof (cases b)
case (fields t u v w)
then show ?thesis using "1" Inr by (cases v) auto
qed
qed
qed auto
definition nt_from_pt :: "('n, 't) parse_table → 'n fset" where
"nt_from_pt pt = fst |`| fmdom pt"
definition parse_ind_meas_sym ::
"('n, 't) parse_table → ('n, 't) symbol → ('t × 's) list → 'n fset → nat ×
"parse_ind_meas_sym pt s ts vis = (length ts, fcard (nt_from_pt pt |-| vis), 0)"
definition parse_ind_meas_sym_list ::
"(', 't) prse_table → ('n, 't) symbol list → ('t × 's) list → 'n fset → nat × nat × nat"
where
"parse_ind_meas_sym_list pt ss ts vis = (length ts, fcard (nt_from_pt pt |-| vis), length ss + 1)"
definition parse_ind_meas :: "('n, 't) parse_table → ('n, 't) symbol + ('n, 't) susing parseSymbol_ts_contains_remainder parseGamma_node(2) A(3)
('t × 's) list → 'n fset → nat × nat × nat" where
"parse_ind_meas pt ss ts vis = (length ts, fcard (nt_from_pt pt |-| vis),
(case ss of Inl ss' → 0 | Inr ss' → length ss' + 1))"
definition lex_triple ::
"('a × 'a) set → ('b × 'b) set → ('c × 'c) set → (('a × 'b × 'c) ×
where "lex_triple ra rb rc = ra <*lex*> (rb <*lex*> rc)"
lemma in_lex_triple[simp]: "((a, b, c), (a', b', c')) ∈ lex_triple r s t
⟷ (a, a') \< proof)
by (auto simp:lex_triple_def)
lemma wf_lex_triple[intro!]:
assumes "wf ra" "wf rb" "wf rc"
shows "wf (lex_triple ra rb rc)"
by (simp add: assms parse.lex_triple_def wf_lex_prod)
definition mlex_triple :: "('a → nat \<imes
"mlex_triple f = inv_image (lex_triple less_than less_than less_than) f"
lemma parseSymbol_length_bound_partial:
"parseSymbol_parseGamma_dom (Inl (pt, s, ts, vis))
==>
then show 12by (split: prod.)
"parseSymbol_parseGamma_dom (Inr (pt, n, gamma, ts, vis))
==> (∧tr r. parseGamma pt n gamma ts vis = RESULT tr r ==> length r ≤ length ts)"
proof (induction rule: parseSymbol_parseGamma.pinduct)
case (1 pt
then show ?case
by (simp add: parseSymbol.psimps(1))
next
case (2 pt a t ts vis)
then show ?case
by (simp add: parseSymbol.psimps(2) split: if_splits)
next
case (3 ptx tsvis)
then show ?case by (auto simp add: parseSymbol.psimps(3) split: if_splits option.splits)
next
caseusing parseSymbol_parseGamma_sound[ x="Inl (pt, s, (w @ r), {||})"]
then show ?case by (auto simp add: parseGamma.psimps(1))
next
case (5 pt n s gamma' ts vis)
then show ?case
by (fastforce simp add: parseGamma.psimps(2) split: return_type.splits parse_tree.splits)
qed
lemma fcard_diff_insert_less:
assumes "x |∉| vis" "fmlookup pt (x,peek ts) = Some (x,ss)"
shows "fcard (nt_from_pt pt - (finsert x vis)) < fcard (nt_from_pt pt - vis)"
proof -
from assms(2) have "x |∈| nt_from_pt pt" by (metis fimage_eqI fmdomI fst_conv nt_from_pt_def)
then have "x |∈
then show ?thesis by (metis fcard_fminus1_less fminus_finsert)
qed
termination
proof (relation "mlex_triple (java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 0
Inl (pt, s, ts, vis) → java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 47
| Inr (pt, n, ss, ts, vis) → parse_ind_meas_sym_listassumes "parse_table_cor pt g"
case 1
then show ?case by (simp add: mlex_triple_def wf_lex_triple)
next
case (2 pt x ts vis s x' gamma)
have "fcard (nt_from_pt pt - (finsert x vis)) < fcard (nt_from_pt pt - vis)"
using "2" fcard_diff_insert_less by fastforce
thenjava.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 97
auto
next
case (3 tmajava.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 29
then show ?case unfolding mlex_triple_def parse_ind_meas_sym_list_def parse_ind_meas_sym_def by
next
case (4 pt s gamma' ts vis y z str r)
then\Longrightarrow \forallvis java.lang.StringIndexOutOfBoundsException: Range [73, 47) out of bounds for length 104
by (fastforce dest: parseSymbol_length_bound_partialor (parseGamma pt y ss (w @ r) vis = RESULT v r))"
qed
fun parse ::
"('n, 't) ll1_parse_table → ('n, 't) symbol → ('t × (nduction rule sym_derives_prefix_gamma_derives_prefixinducts
where
"parse (PT pt) s ts = parseSymbol pt s ts {||}"
| "parse (ERROR_GRAMMAR_NOT_LL1_AMB_LA l) s ts =
(case l of (a, p1, p) → GRAMMAR_NOT_LL1 ''Grammar not LL1, ambigous lookahead '' a)"
fun concatWithSep :: "string → string → string" where
then show ?case by auto
| "concatWithSep [] acc = acc"
| "concatWithSep s [] = s"
| "concatWithSep s (c # acc) = (if c = CHR '' '' then s @ c # acc else s @ '' '' @ c # acc)"
fun parseTreeToString :: "('n, 't ×
"parseTreeToString (Leaf (a, s)) = ''('' @ showT a @ '', '' @ showS s @ '')''"
| "parseTreeToString (Node n ls) = foldr concatWithSep (map parseTreeToString ls) ''''"
fun parseToString ::
"('n, 't) ll1_parse_table → ('n, 't) symbol → "fmlookup pt (x,peek (w @ r)) = Some (x, gamma)"
"parseToString (PT pt) s ts = (case parseSymbol pt s ts {||} of
RESULT t [] → parseTreeToString t)"
| "paseoSting(ERRR_GRMMRN_L_M_A l)s s 'rmmr otLL, mbigus lokha ''@
(case l of (a, p1, p) → (case a of LA t →exi>m y ts'. parseSymbol pt (NT x) (w @ r) vis = ERROR m y ts')
subsection ‹Soundness›
inductive sym_derives_prefix ::
"('n, 't) grammar → ('n, 't) symbol → ('t × 's) list
→ ('n, 't × 's) parse_tree → ('t × 's) list → bool"
and gamma_derives_prefix :: "('n, 't) grammar → 'n → ('n, 't) symbol list → ('t × 's) list
→ ('n, 't × 's) parse_tree → ('t × 's) list → bool" for g
where
T_sdp: "sym_derives_prefix g (T a) [(a, s)] (Leaf (a, s)) r"
| NT_sdp: "(x, gamma) ∈ set (prods g) ==> lookahead_for (peek (w @ r)) x gamma g
==> gamma_derives_prefix g x gamma w t r ==> sym_derives_prefix g (NT x) w t r"
| Nil_gdp: "gamma_derives_prefix g x [] [] (Node x []) r"
| Cons_gdp: "sym_derives_prefix g s wpre v (wsuf @ r)
==> gamma_derives_prefix g n ss wsuf (Node n vs) r
==> gamma_derives_prefix g n (s#ss) (wpre @ wsuf) (Node n (v # vs)) r"
lemma parseSymbol_ts_contains_remainder:
"∧t r. parseSymbol pt s ts vis = RESULT t r ==> ∃ts'. ts' @ r = ts" and
parseGamma_ts_contains_remainder:
"∧t r. parseGamma pt n gamma ts vis = RESULT t r ==> ∃ts'. ts' @ r = ts"
proof (induction pt s ts vis and pt n gamma ts vis rule: parseSymbol_parseGamma.induct)
case (5 pt n s gamma' ts vis)
then show ?case by (fastforce split: return_type.splits parse_tree.splits option.splits if_splits)
qed (auto split: return_type.splits parse_tree.splits option.splits if_splits)
lemma parse_meas_induct:
assumes "∧y. (∧x. ((x,y) ∈ mlex_triple (λx. case x of
Inl (pt, s, ts, vis) → parse_ind_meas_sym pt s ts vis
| Inr (pt, x, ss, ts, vis) → parse_ind_meas_sym_list pt ss ts vis) ==> P x)) ==> P y"
shows "P z"
using assms
by (auto intro: wf_induct_rule[where r = "mlex_triple (λx. case x of
Inl (pt, s, ts, vis) → parse_ind_meas_sym pt s ts vis
| Inr (pt, x, ss, ts, vis) → parse_ind_meas_sym_list pt ss ts vis)"]
simp add: mlex_triple_def wf_lex_triple)
lemma parseGamma_node: "parseSymbol pt s ts vis = RESULT v r ==> True"
"parseGamma pt x gamma ts vis = RESULT v r ==> ∃ls. v = Node x ls"
proof (induction pt s ts vis and pt x gamma ts vis arbitrary: and v r
rule: parseSymbol_parseGamma.induct)
case (5 pt n s' gamma' ts vis)
obtain a b where A: "parseSymbol pt s' ts vis = RESULT a b"
using 5(2,3) by (auto split: return_type.splits parse_tree.splits if_splits)
show ?case
proof (cases gamma')
case Nil
then have "parseGamma pt n gamma' b (if length b < length ts then {||} else vis)
= RESULT (Node n []) b"
by auto
then show ?thesis using 5(3) A
by (auto split: return_type.splits parse_tree.splits)
next
case (Cons x'' gamma'')
obtain ls where "v = Node n ls" using 5(2,3) A by
(auto split: return_type.splits parse_tree.splits)
then show ?thesis by auto
qed
qed auto
lemma parseSymbol_parseGamma_sound: "case x of Inl (pt, s, ts, vis) → parse_table_correct pt g
⟶ parseSymbol pt s ts vis = RESULT v r ⟶ (∃w. w @ r = ts ∧ sym_derives_prefix g s w v r)
| Inr (pt, n, gamma, ts, vis) → parse_table_correct pt g
⟶ (parseGamma pt n gamma ts vis = RESULT v r
⟶ (∃w. w @ r = ts ∧ gamma_derives_prefix g n gamma w v r))"
proof (induction arbitrary: v r rule: parse_meas_induct)
case (1 y)
note IH = "1"
{
fix pt s ts vis
assume A: "y = Inl (pt, s, ts, vis)" "parse_table_correct pt g"
"parseSymbol pt s ts vis = RESULT v r"
consider (T) a lex ts' where "s = T a" "ts = (a,lex)#ts'" "v = Leaf (a, lex)" "r = ts'"
| (NT) x ss where "s = NT x" "x |∉| vis" "fmlookup pt (x, peek ts) = Some (x, ss)"
"parseSymbol pt s ts vis = parseGamma pt x ss ts (finsert x vis)"
using A(3) by (cases s; cases ts) (auto split: if_splits option.splits)
then have "∃w. w @ r = ts ∧ sym_derives_prefix g s w v r"
proof cases
case T
then show ?thesis by (auto simp add: T_sdp)
next
case NT
then have "(Inr (pt, x, ss, ts, (finsert x vis)), y) ∈ mlex_triple
(λx. case x of Inl (pt, s, ts, vis) → parse_ind_meas_sym pt s ts vis
| Inr (pt, x, ss, ts, vis) → parse_ind_meas_sym_list pt ss ts vis)"
unfolding mlex_triple_def parse_ind_meas_sym_def parse_ind_meas_sym_list_def
using A(1) fcard_diff_insert_less by simp
then obtain w where " w @ r = ts" "gamma_derives_prefix g x ss w v r"
using IH[of "Inr (pt, x, ss, ts, (finsert x vis))"] A NT by auto
then show ?thesis using A(2) NT(1,3) NT_sdp pt_sound_def by fastforce
qed
}
note 1 = this
{
fix pt x ss ts vis
assume A: "y = Inr (pt, x, ss, ts, vis)" "parse_table_correct pt g"
"parseGamma pt x ss ts vis = RESULT v r"
consider (Nil) "ss = []"
| (ConsLe) s ss' t tls r1 where "ss = s#ss'"
"parseSymbol pt s ts vis = RESULT t r1" "length r1 < length ts"
"parseGamma pt x ss' r1 {||} = RESULT (Node x tls) r" "v = Node x (t # tls)"
| (ConsEq) s ss' t tls where "ss = s#ss'" "parseSymbol pt s ts vis = RESULT t ts"
"parseGamma pt x ss' ts vis = RESULT (Node x tls) r" "v = Node x (t # tls)"
proof (cases ss)
case Nil
then show ?thesis by (simp add: that(1))
next
case (Cons s ss')
then show ?thesis
using parseSymbol_ts_contains_remainder parseGamma_node(2) A(3)
by (fastforce simp: ConsLe ConsEq split: return_type.splits if_splits)
qed
then have "∃w. w @ r = ts ∧ gamma_derives_prefix g x ss w v r"
proof (cases)
case Nil
then show ?thesis using A(3) Nil_gdp by auto
next
case ConsLe
obtain wpre wsuf where "ts = wpre @ wsuf @ r" "wsuf @ r = r1"
using parseGamma_ts_contains_remainder A(3) parseSymbol_ts_contains_remainder ConsLe(2,4)
by metis
then have "gamma_derives_prefix g x ss' wsuf (Node x tls) r"
using IH[of "Inr (pt, x, ss', r1, {||})"] A(1,2) ConsLe(3,4)
unfolding mlex_triple_def parse_ind_meas_sym_list_def
by (auto simp add: A(1))
moreover have "sym_derives_prefix g s wpre t (wsuf @ r)"
using IH[of "Inl (pt, s, ts, vis)"] ‹ts = wpre @ wsuf @ r› ‹wsuf @ r = r1› A ConsLe(2)
unfolding mlex_triple_def parse_ind_meas_sym_def parse_ind_meas_sym_list_def
by (auto simp add: A(1))
ultimately show ?thesis by (simp add: ConsLe(1,5) Cons_gdp ‹ts = wpre @ wsuf @ r›)
next
case ConsEq
obtain w where "ts = w @ r" using ConsEq(3) parseGamma_ts_contains_remainder by
fastforce
have "length ss' < length ss" by (cases w) (auto simp add: ‹ts = w @ r› ConsEq(1))
then have "gamma_derives_prefix g x ss' w (Node x tls) r"
using IH[of "Inr (pt, x, ss', ts, vis)"] A(1,2) ConsEq(3)
unfolding mlex_triple_def parse_ind_meas_sym_list_def
by (auto simp add: A(1) ‹ts = w @ r›)
moreover have "sym_derives_prefix g s [] t ts"
using IH[of "Inl (pt, s, ts, vis)"] ‹ts = w @ r› A ConsEq(2)
unfolding mlex_triple_def parse_ind_meas_sym_def parse_ind_meas_sym_list_def
by (auto simp add: A(1))
ultimately show ?thesis using ConsEq(1,4) Cons_gdp ‹ts = w @ r› by fastforce
qed
}
note 2 = this
then show ?case using 1 2 by (cases y) (auto split: prod.splits)
qed
theorem parse_sound: "parse_table_correct pt g ==> parse (PT pt) s (w @ r) = RESULT v r
==> sym_derives_prefix g s w v r"
using parseSymbol_parseGamma_sound[where x = "Inl (pt, s, (w @ r), {||})"]
by auto
subsection "Completeness"
lemma parseSymbol_parseGamma_complete_or_error:
assumes "parse_table_correct pt g"
shows "sym_derives_prefix g s w v r
==> (∀vis. (∃m x ts'. parseSymbol pt s (w @ r) vis = ERROR m x ts')
∨ (parseSymbol pt s (w @ r) vis = RESULT v r))"
and "gamma_derives_prefix g y ss w v r
==> (∀vis. (∃m x ts'. parseGamma pt y ss (w @ r) vis = ERROR m x ts')
∨ (parseGamma pt y ss (w @ r) vis = RESULT v r))"
proof (induction rule: sym_derives_prefix_gamma_derives_prefix.inducts)
case (T_sdp a r)
then show ?case by auto
next
case (NT_sdp x gamma w r v)
have "fmlookup pt (x,peek (w @ r)) = Some (x, gamma)"
using NT_sdp.IH(1) NT_sdp.IH(2) assms pt_complete_def by fastforce
then have "(∃m y ts'. parseSymbol pt (NT x) (w @ r) vis = ERROR m y ts')
∨ parseSymbol pt (NT x) (w @ r) vis = RESULT v r" for vis
proof (cases "x |∈| vis")
case True
then show ?thesis by simp
next
case False
then have "parseSymbol pt (NT x) (w @ r) vis = parseGamma pt x gamma (w @ r) (finsert x vis)"
using ‹fmlookup pt (x, peek (w @ r)) = Some (x, gamma)› by auto
then show ?thesis using NT_sdp.IH(4) by auto
qed
then show ?case by auto
next
case (Nil_gdp r)
then show ?case by auto
next
case (Cons_gdp s wpre v wsuf r n ss vs)
then have "(∃m x ts'. parseGamma pt n (s # ss) ((wpre @ wsuf) @ r) vis = ERROR m x ts')
∨ parseGamma pt n (s # ss) ((wpre @ wsuf) @ r) vis = RESULT (Node n (v # vs)) r" for vis
proof -
have "∃m x ts'. parseSymbol pt s (wpre @ wsuf @ r) vis = ERROR m x ts'
∨ parseSymbol pt s (wpre @ wsuf @ r) vis = RESULT v (wsuf @ r)" using Cons_gdp.IH(2) by auto
moreover have "∃m x ts'. parseGamma pt n ss (wsuf @ r) vis = ERROR m x ts'
∨ parseGamma pt n ss (wsuf @ r) vis = RESULT (Node n vs) r" using Cons_gdp(4) by auto
moreover have "∃m x ts'. parseGamma pt n ss (wsuf @ r) {||} = ERROR m x ts'
∨ parseGamma pt n ss (wsuf @ r) {||} = RESULT (Node n vs) r" using Cons_gdp(4) by auto
ultimately show ?thesis by (cases "parseSymbol pt s (wpre @ wsuf @ r) vis") auto
qed
then show ?case by auto
qed
lemma parse_complete_or_error: "parse_table_correct pt g ==> sym_derives_prefix g s w v r
==> ∃m x ts'. parse (PT pt) s (w @ r) = ERROR m x ts'
∨ (parse (PT pt) s (w @ r) = RESULT v r)"
using parseSymbol_parseGamma_complete_or_error by fastforce
subsection ‹Error-free Termination›
inductive sized_first_sym :: "('n, 't) grammar → 't lookahead → ('n, 't) symbol → nat → bool"
for g where
SzFirstT: "sized_first_sym g (LA y) (T y) 0"
| SzFirstNT: "(x, gpre @ s # gsuf) ∈ set (prods g) ==> nullable_gamma g gpre
==> sized_first_sym g la s n ==> sized_first_sym g la (NT x) (Suc n)"
lemma first_sym_exists_size: "first_sym g la s ==> ∃n. sized_first_sym g la s n"
using SzFirstT SzFirstNT
by -(induction rule: first_sym.induct; fastforce)
lemma sized_fs_fs: "sized_first_sym g la s n ==> first_sym g la s"
by (induction rule: sized_first_sym.induct) (auto simp add: FirstT FirstNT)
lemma medial : "pre @ s # suf = pre' @ s' # suf'
==> s ∈ set pre'∨ s' ∈ set pre ∨ pre = pre' ∧ s = s' ∧ suf = suf'"
proof (induction pre arbitrary: pre')
case Nil
then show ?case by (cases pre') auto
next
case (Cons a pre)
then show ?case by (cases pre') auto
qed
lemma nullable_sym_in: "nullable_gamma g gamma ==> s ∈ set gamma ==> nullable_sym g s"
proof (induction gamma)
case (Cons s' gamma)
have "nullable_gamma g gamma" using Cons.prems(1) by (cases rule: nullable_gamma.cases)
moreover have "nullable_sym g s'" using Cons.prems(1) by (cases rule: nullable_gamma.cases)
ultimately show ?case using Cons.IH Cons.prems(2) by (cases "s = s'") auto
qed simp
lemma nullable_split: "nullable_gamma g (xs @ ys) ==> nullable_gamma g ys"
proof (induction xs arbitrary: ys)
case Nil
then show ?case by auto
next
case (Cons s xs)
from Cons.prems have "nullable_gamma g (xs @ ys)" by (cases rule: nullable_gamma.cases) auto
then show ?case using Cons.IH by auto
qed
lemma first_gamma_split:
"first_gamma g la ys ==> nullable_gamma g xs ==> first_gamma g la (xs @ ys)"
proof (induction xs)
case Nil
then show ?case by auto
next
case (Cons s xs)
from Cons.prems(2) have "nullable_gamma g xs" by (cases) auto
then have "first_gamma g la (xs @ ys)" using Cons.IH Cons.prems(1) by auto
then obtain xs' s' ys' where "first_sym g la s'" "nullable_gamma g xs'" "xs @ ys = xs' @ s' # ys'"
by (cases rule: first_gamma.cases) auto
have "nullable_sym g s" using Cons.prems(2) by (cases) auto
then have "nullable_gamma g (s # xs')" by (simp add: NullableCons ‹nullable_gamma g xs'›)
then show ?case using FirstGamma[where gpre = "s # xs'" and s = s' and gsuf = "ys'"] by
(simp add: ‹first_sym g la s'› ‹xs @ ys = xs' @ s' # ys'›)
qed
lemma follow_pre: "(x, pre @ suf) ∈ set (prods g) ==> s ∈ set pre ==> nullable_gamma g pre
==> first_gamma g la suf ==> follow_sym g la s"
proof goal_cases
case 1
then obtain l1 l2 where l1_l2_def: "pre = l1 @ s # l2" by (metis split_list)
then show ?case
proof (cases s)
case (NT x)
have "nullable_gamma g (l1 @ NT x # l2)" using "1"(3) by (auto simp add: l1_l2_def NT)
then have "nullable_gamma g l2" using nullable_split[where xs = "l1 @ [NT x]"] by auto
then have "first_gamma g la (l2 @ suf)" by (simp add: "1"(4) first_gamma_split)
then show ?thesis using FollowRight[where gsuf = "l2 @ suf"] NT "1"(1) l1_l2_def by auto
next
case (T t)
then show ?thesis using "1"(2,3) nullable_sym.cases nullable_sym_in by blast
qed
qed
lemma no_first_follow_conflicts:
assumes "parse_table_correct tbl g"
shows "first_sym g la s ==> nullable_sym g s ==> ¬ follow_sym g la s"
unfolding not_def
proof (intro impI, induction rule: first_sym.induct)
case (FirstT y)
then show ?case by (cases rule: nullable_sym.cases)
next
case (FirstNT x gpre s gsuf la)
from FirstNT.prems(1) obtain ys where ys_props: "(x, ys) ∈ set (prods g)" "nullable_gamma g ys" by
cases auto
have ys_eq: "ys = gpre @ s # gsuf"
proof -
have "lookahead_for la x (gpre @ s # gsuf) g"
by (simp add: FirstGamma FirstNT.hyps(2,3) lookahead_for_def)
moreover have "lookahead_for la x ys g"
by (simp add: FirstNT.prems(2) ys_props(2) lookahead_for_def)
ultimately show ?thesis using assms by
(metis FirstNT.hyps(1) Pair_inject ys_props(1) option.inject pt_complete_def)
qed
have "nullable_sym g s" using ys_props(2) ys_eq nullable_sym_in by fastforce
then show ?case
proof (cases s)
case (NT x)
have "nullable_gamma g gsuf" using nullable_split[where xs = "gpre @ [s]"] ys_props(2) ys_eq by
auto
then have "follow_sym g la s" using FirstNT.hyps(1) FirstNT.prems(2) FollowLeft NT by fastforce
then show ?thesis using FirstNT.IH ‹nullable_sym g s› by auto
next
case (T t)
show ?thesis using ‹nullable_sym g s› T by (cases rule: nullable_sym.cases) auto
qed
qed
lemma first_sym_rhs_eqs: "parse_table_correct t g ==> (x, pre @ s # suf) ∈ set (prods g)
==> (x, pre' @ s' # suf') ∈ set (prods g) ==> nullable_gamma g pre ==> nullable_gamma g pre'
==> first_sym g la s ==> first_sym g la s' ==> pre = pre' ∧ s = s' ∧ suf = suf'"
proof (goal_cases)
case 1
have "pre @ s # suf = pre' @ s' # suf'"
proof -
have "lookahead_for la x (pre @ s # suf) g" by (simp add: "1"(4,6) FirstGamma lookahead_for_def)
moreover have "lookahead_for la x (pre' @ s' # suf') g" by
(simp add: "1"(5,7) FirstGamma lookahead_for_def)
ultimately show ?thesis
using "1"(1-3) unfolding pt_complete_def by (metis Pair_inject option.inject)
qed
then consider (s_in_pre') "s ∈ set pre'" | (s'_in_pre) "s' ∈ set pre"
| (eq) "pre = pre' ∧ s = s' ∧ suf = suf'" using medial by fastforce
then show ?case
proof cases
case s_in_pre'
then have "nullable_sym g s" using "1"(5) using nullable_sym_in by auto
moreover have "follow_sym g la s"
proof -
have "first_gamma g la (s' # suf')" using "1"(7) FirstGamma[of _ "[]" _ s'] NullableNil by
auto
then show ?thesis using "1"(3,5) s_in_pre' follow_pre[where suf = "s' # suf'"] by auto
qed
ultimately show ?thesis using "1"(1,6) no_first_follow_conflicts by auto
next
case s'_in_pre
then have "nullable_sym g s'" using "1"(4) using nullable_sym_in by auto
moreover have "follow_sym g la s'"
proof -
have "first_gamma g la (s # suf)" using "1"(6) FirstGamma[of _ "[]" _ s] NullableNil by auto
then show ?thesis using "1"(2,4) s'_in_pre follow_pre[where suf = "s # suf"] by auto
qed
ultimately show ?thesis using "1"(1,7) no_first_follow_conflicts by auto
next
case eq
then show ?thesis by blast
qed
qed
lemma sized_first_sym_det:
assumes "parse_table_correct t g"
shows "sized_first_sym g la s n ==> (∀n'. s = s' ⟶ sized_first_sym g la s' n' ⟶ n = n')"
proof (induction arbitrary: s' rule: sized_first_sym.inducts)
case (SzFirstT g y)
then show ?case by (auto, cases rule: sized_first_sym.cases) auto
next
case (SzFirstNT x pre s suf la n)
have "s' = NT x ⟶ sized_first_sym g la s' n' ⟶ Suc n = n'" for n'
proof (intro impI, goal_cases)
case 1
obtain gpre gsuf s0 n0 where s0_props: "(x, gpre @ s0 # gsuf) ∈ set (prods g)"
"nullable_gamma g gpre" "sized_first_sym g la s0 n0" "n' = Suc n0"
using 1(1) by (cases rule: sized_first_sym.cases[OF 1(2)]) auto
then have "first_sym g la s" "first_sym g la s0" using SzFirstNT.hyps(3) sized_fs_fs by auto
then have "s = s0" using first_sym_rhs_eqs SzFirstNT.hyps s0_props assms by fastforce
then have "n = n0" using SzFirstNT.IH ‹sized_first_sym g la s0 n0› by auto
then show ?case using ‹n' = Suc n0› by auto
qed
then show ?case by auto
qed
lemma sized_first_sym_np: "nullable_path g la x y ==> first_sym g la y
==> ∃nx ny. sized_first_sym g la x nx ∧ sized_first_sym g la y ny ∧ ny < nxcases x <in|
proof caseTrue
case (DirectPath x gamma g gpre z gsuf la)
then obtain n where "zdfrtsmgl N )n using first_sym_exist by blast
then have "sized_first_sym g la (NT x) (Suc n)" using DirectPath.hyps by (simp add: SzFirstNT)
then show ?case using ‹sized_first_sym g la (NT z) n› by blast
next
case (IndirectPath x gamma g gpnext
then obtain nx ny where nx_ny_ex:
"sized_first_sym g la (NT y) nx case
then have "sized_first_sym g la (NT x) (Suc nx)" using IndirectPath.hyps by (simp add: SzFirstNT)
then show ?case using nx_ny_ex less_SucI by blast
qed
inductive sized_nullable_sym :: java.lang.StringIndexOutOfBoundsException: Index 103 out of bounds for length 41
and sized_nullable_gamma :: "('n, 't) grammar → ('n, 't) symbol list → nat → bool" for g where
SzNullableSym: "(x, gamma) ∈ set (prods ad_for_def
==> sized_nullable_gamma g gamma n ==> sized_nullable_sym g (NT x) (Suc n)"
| SzNullableNil: "sized_nullable_gamma g [] 0"
usin 1"(-) bym optioni)
==> sized_nullable_gamma g (s # ss) (n + n')"
lemma sized_ng_ng: "sized_nullable_sym g s n ==> nullable_sym g s"
"sized_nullable_gamma g gamma n ==> nullable_gamma g gamma"
by (induction rule: sized_nullable_sym_sized_nu.inducts)
(auto simp add: NullableSym
ng_sized_ng: "g \>\>. g java.lang.StringIndexOutOfBoundsException: Range [90, 89) out of bounds for length 92
"nullable_gamma g gamma ==> ∃n. sized_nullable_gamma g gamma n"
using SzNullableSym SzNullableNil SzNullableCons
by (java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 37
lemma sized_nullable_sym_det':
assumes"parse_table_correct pt g"
shows "sized_nullable_sym g s n
==> (∧n'. follow_sym g la s ==>1"3 [ ] auto
and "sized_nullable_gamma g gsuf n ==> (∧x gpre n'. (x, gpre @ gsuf) ∈ set (prods g)
==> follow_sym g la (NT x) ==> sized_nullable_gamma g gsuf n' ==> n = n')"
proof (induction rule: sized_nullable_sym_sized_nullable_gamma.inducts)
case (SzNullableSym x gamma n)
from SzNullableSym.prems(2) obtain n0 gamma0 where "(x, gamma0) ∈4)using nullable_sym by aut
"sized_nullable_gamma g gamma0 n0" "n' = Suc n0" by (cases) auto
have "gamma0 = gamma"
proof -
have "lax f
using sized_ng_ng SzNullableSym.prems(1) ‹"'i_r olwpeweesf=" u" yat
then have lookup_1: "fmlookup pt (x, la) = Some (x, gamma0)"
asm ‹ set (prods g\se at ipad tlt_e)
have "lookahead_for la x gamma g" unfolding lookahead_for_def
using sized_ng_ng SzNullableSym.prems(1) SzNullableSym.IH(2) by blast
then have lookup_2: "fmlookup pt (x, la) = Some (x, gamma)" using assms SzNullableSym.IH(1)
by (auto simp add: pt_complete_def)
show ?thesis using lookup_1 lookup_2 by auto
qed
then have "n0 = n"
using ‹sized_nullable_gamma g gamma0 n0›next
SzNullableSym.prems(1) by auto
then show ?case by (simp add: ‹
case SzNullableNil
then show ?case by (cases rule: parse.sized_nullable_gamma.cases) auto
case (SzNullableCons s n1 ss n2 x)
from SzNullableCons.prems(3) obtain n1' n2' where
"sized_nullable_sym g s n1'" "sized_nullable_gamma g ss n2'" "n' = n1' + n2'" by (cases) auto
have "follow_sym g la s"
proof (cases s)
case (NT x1)
have "nullable_gamma g ss" using sized_ng_ng SzNullableCons.IH(3) by fastforce
then show ?thesis using FollowLeft NT SzNullableCons.prems(1,2) by fastforce
next
case (T x2)
from ‹sized_nullable_sym g s n1› show ?thesis using T by (cases) auto
qed
then have "n1 = n1'" using SzNullableCons.IH(2)[of n1'] ‹ (∀s' n' \< n = n')"
moreover have "n2 = n2'"
using SzNullableCons.IH(4)[of x "gpre @ [s]" n2'] ‹sized_nullable_gamma g ss n2'›
by (simp add: SzNullableCons.prems(1,2))
ultimately show ?case using ‹n' = n1' + n2'› by auto
sized_nullable_sym_det:
assumes"parse_table_correct t g"
shows "sized_nullable_sym g s n ==> follow_sym g la s ==> sized_nullable_sym g s n' ==> n = n'"
using sized_nullable_sym_det' assms by blast
sym_in_gamma_size_le: "nullable_gamma g gamma ==> s ∈ set gamma
==> ∃n n'. sized_nullable_sym g s n ∧ sized_nullable_gamma g gamma n' ∧ n ≤ n'"
(induction gamma)
case Nil
then show ?case by auto
case (Cons a gamma)
from Cons.prems(1) have nullable: "nullable_sym g a" "nullable_gamma g gamma" by
(cases rule: nullable_gamma.cases, auto)+
then show ?case
proof (cases "a = s")
case True
then show ?thesis using SzNullableCons nullable ng_sized_ng by fastforce
next
case False
then show ?thesis using Cons.IH Cons.prems(2) SzNullableCons nullable ng_sized_ng(1) by
fastforce
qed
sized_ns_np:
assumes "(x, pre @ NT y # suf) ∈ set (prods g)" "nullable_gamma g (pre @ NT y # suf)"
"nullable_sym g (NT y)"
shows "∃nx ny. sized_nullable_sym g (NT x) nx ∧ sized_nullable_sym g (NT y) ny ∧ ny < nx"
-
obtain n n' where
"sized_nullable_sym g (NT y) n" "sized_nullable_gamma g (pre @ NT y # suf) n'" "n ≤ n'"
using sym_in_gamma_size_le[of g "pre @ NT y # suf" "NT y"] assms(2) by auto
then have "sized_nullable_sym g (NT x) (Suc n')"
using SzNullableSym[where gamma = "pre @ NT y # suf"] assms(1) by auto
then show ?thesis using ‹> n'› open>sized_nullab g (NT y) n› blast
(RROR_GRAMMAR_NOT_LL1_Al) s ts = ''Grammar not LL1, ambigous lookahead '' @
shows "nullable_path g la x y ==> parse_table_correct t g ==> nullable_sym g x
==> follow_sym g la x
==> ∃nx ny. sized_nullable_sym g x nx ∧ sized_nullable_sym g y ny ∧ ny < nx"
(induction rule: nullable_path.induct)
case (DirectPath x gamma g pre y suf la)
from DirectPath.prems(2) obtain ys where "(x, ys) ∈ set (prods g)" "nullable_gamma g ys" by
(cases rule: nullable_sym.cases) auto
DrcPt.ys(4 osd (s_gm)"frt_gamma g laama
(null_gamma) "nllae_ama""olwsym g (NT x)"
unfolding lookahead_for_def by auto
then show ?case
proof cases
case fst_gamma
then have "first_sym g la (NT x)" using DirectPath.hyps(1) FirstNT by cases autst → bool" for g
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 76
(auto simp add: no_first_follow_conflicts)
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 55
next
case null_gamma
java.lang.StringIndexOutOfBoundsException: Range [30, 28) out of bounds for length 100
java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 93
java.lang.StringIndexOutOfBoundsException: Range [5, 6) out of bounds for length 5
then sh caseb (astforce pt: retrn_tpe.sitsprse_resotin.pis f_pis
ia am peygsuf l )
from IndirectPath.hyps(4) consider (fst_gamma) "first_gamma gla gamma"
| (n nl (pt, s,t, is \>prs_in_ea_ymtst vs
oldinglookahead_for_def yauto
then show ?ca
proof cases
case fst_tro: wwf_induct_rule[wher metipl(\lambda.cs xo
nhv " (N x)"usn ndirctathhy() FrtN bycas auto
then have "¬ ndrects12)b
(auto simp add: no_firs
then show ?thesis using IndirectPath.prems(3) by auto
next
senl_gama
have "nullable_sym g (NT y)" using IndirectPath
fastforce
mma
where xs = "gpre @ [NT y]" by auto
then have "follow_sym g la (NT y)" using null_gamma IndirectPath.hyps(1,2) by
(auto simp add: FollowLeft)
then obtain ny nz where
"sized_nullable_sym g (NT y) ny" "sized_nullable_sym g (NT show ?ase
have"parseGammaptn gamma ( length b length ts then {|}else )
obtain nx ny' where
"sized_nullable_sym g (NT x) nx" " by a split return_typesplits parse_tree.plits)
obtain where nls using(2,3)A
then have then t by auto
\<open>sized_nullable_sym g (NT
then have "lemma parseSymbol_parseGamma_sound:"asex of pt ,,vis <>parse_table_correct java.lang.StringIndexOutOfBoundsException: Range [106, 107) out of bounds for length 106
then show ?thesis using \<open>sized_nullable_sym g (NT x) nx\<close> \<open>sized_nullable_sym |Inr(,n gamma, ts vis)\<Rightarrow parse_table_correct pt java.lang.StringIndexOutOfBoundsException: Range [70, 71) out of bounds for length 70
auto
qed
qed
nullable_path_exists_production n NT java.lang.StringIndexOutOfBoundsException: Range [67, 68) out of bounds for length 67
\ <>java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 101
by( :nullable_path.)auto
lemma ll1_parse_table_impl_no_left_recursion:
" tbl ( : ',') grammar)"
shows\notleft_recursive g(T)lajava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
assume then have( (t x ss f vis) y <>mlex_triple
"lookahead_for la g"
using | Inr (pt,,, ts,vis)\Rightarrow parse_ind_meas_sym_listss ts )"
then first_gamma gamma"|"g gamma follow_sym gla (NT )"
by (auto simp: lookahead_for_def)
then show? using()NT(3 by
()
case :y=Inrpt , ts ""java.lang.StringIndexOutOfBoundsException: Range [66, 65) out of bounds for length 71
thenhave" (NT )"usingFirstNT<(, )\in set(prods\close cases)auto
whereg( x ""g)java.lang.StringIndexOutOfBoundsException: Index 93 out of bounds for length 93
"ny < ) ss'ttls where ss = sss'"p pt vis= tts
fastforce
then? \openny nx\<> by auto
next
case 2
then ?
(auto simp add: NullableSym)
thenobtain nn " NT x "" gNT x)' "n'<n"
using "2"(2) x_left_rec assms exist_decreasing_nullable_sym_sizes_in_null_path
then show ?thesis using "2"(2) assms java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 17
usingparseGamma_ts_contains_remainderA3 ConsLe2,4)
input_length_lt_or_nullable_symcase (, , <java.lang.StringIndexOutOfBoundsException: Range [84, 83) out of bounds for length 109
longrightarrow>pttsvis r\longrightarrow lengthr<length \orjava.lang.StringIndexOutOfBoundsException: Range [119, 116) out of bounds for length 120
| Inr (t ss, ts vis) \Rightarrow parse_table_correct pt g \<longrightarrow> parseGamma pt x ss ts vis = RESULT v r
\<longrightarrow> length r < length ts \<or> nullable_gamma g ss"
proof (induction arbitrary: v (auto simp add:A()java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
case (1 y)
note IH = 1
then show?
proof(ases y
case (Inl a)
then pt s ts where " p, s, ts vis"by(casesy auto
have "ength r < length ts \<or> nullable_sym g s"
if "parseSymbol pt s ts vis = RESULT v r IH[ "nr(,x, ss' ts,vis)"]A12 ConsEq()
proof(cases s)
case(T x)
from that obtain ss where parse_ss_simp: "x |\< moreoverhave "sym_derives_prefix g s[ tts
"parseGamma pt x ss ts (finsert x vis) = RESULT v r"
by(:NTsplit optionsplits)
then have "(x, ss) \<in> set (prods g)" using that(2) by (auto simp add: pt_sound_def)
have "fcard (nt_from_pt pt |-| finsert x vis) < fcard (nt_from_pt pt |-| vis)"
usingfcard_diff_insert_lessparse_ss_simp1)byfastforce
then have "length r < length ts \<or> nullable_gamma g ss"
using IH[of "Inr (pt, x, ss, ts, finsert x vis)"] parse_ss_simp(3)
unfolding parse_ind_meas_sym_def parse_ind_meas_sym_list_def
by (auto simp: Inl \<open>a = (pt, s, ts, vis)\<close> that(2))
then show ?thesis using NT NullableSym \<open
next
caseT)
@s#suf= pre' '# suf'
(cases,auto simp:Tsplit: if_splits option.java.lang.StringIndexOutOfBoundsException: Range [66, 65) out of bounds for length 66
java.lang.StringIndexOutOfBoundsException: Range [15, 10) out of bounds for length 31
qed
then ? (simp add:Inl \<open> = (t,ts,vis)<close>)
next
case(Inr a)
thenobtain pt vis where " =(t, x,ss, vis)"by (ases y) auto
java.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 0
"parseGamma pt x ss ts vis = java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 25
proof (cases ss)
case Nil
thenthesis by (imp add:)
next
case (Cons s ss')
from that(1) consider v0 v1 where "parseSymbol pt s ts vis = RESULT v0 ts"
x v1 " = Node x (v0 # v1)"
| v0 v1 r0 where "parseSymbol pt s ts vis = RESULT v0 r0" "length r0 < length ts"
"parseGamma pt x ss' r0 {||} =RESULT (Node x ) r " =Nodex(0#v1"
using parseSymbol_ts_contains_remainder[of pt s
(fastforce: return_type.plits .splits )
then showthen? by :java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 53
case 1
then have proof -
using IH[of "Inl (pt, have "lookahead_for la x (gprl x @s #gsuf)g
unfoldinghavel laxysjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
byauto <> (, ,ts )<losejava.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
moreover c
using IH case ( x
unfolding mlex_triple_def parse_ind_meas_sym_list_def
by (auto java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 12
ultimately show ?thesis using NullableCons Conscase(zFirstNTxthen? <>java.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 78
next
case 2
qed
then show : " <Longrightarrow> (x,pre@ s # )\in> set (prods )
ed
qed
then show ?thesis by (simp add: Inr \<open>a = (pt, x, ssproof (oal_cases
qed
qed
java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
tbl s ts vis= v \g"
using input_length_lt_or_nullable_sym[where x = "Inl (tbl, s, g s0 \<lose>by hesis
lemma error_conditions: "case y of
, s tsvis \<Rightarrow qed
\<ongrightarrow (z|\inthen ?ase
\<or> (\<exists>la. java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 17
| pt x,ss,ts < parse_table_correct g<java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
parseGamma pt x ss tsproof:"nullable_pathg y \<ongrightarrow>gla y
g \and z|\in> vis\<nd ( NTz\or nullable_pathg( ts)sLongrightarrow> <xistsny sized_first_sym lax nx\andsized_first_sym g la ny \<and nx
\<or> (\<exists>la. (left_recursive then show thesis "1"5 'follow_pre[where suf s ']by auto
proof (induction arbitraryultimatelyshow thesis ""1,6 by auto
case ( y)
note IH = "1"
then show ? then have "nullable_sym g s'"t_sym g (NT) n using first_sym_exists_size java.lang.StringIndexOutOfBoundsException: Range [85, 84) out of bounds for length 90
java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 17
case (Inl a)
then pt tsviswhere a=(t ,ts vis"using by blast
then show ?thesis
proof (cases s)
case (NT x)
consider (x_in_vis) "x | case (ndirectPath gamma gpre gsuf ultimately showt "17)no_first_follow_conflictsauto
| (lookup_some_neq) x' ss' where "x |\<notin>| show ?hesisby
"fmlookup pt (x, peek ts) = Some (x'
| assumes"arse_table_correctt g
by
then
then show by(, casesrule .cases auto
java.lang.StringIndexOutOfBoundsException: Range [27, 28) out of bounds for length 27
then have "fcard (nt_from_ptproof (intro impI,goal_cases)
casejava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
then gpre" s0 n0"row ( t <java.lang.StringIndexOutOfBoundsException: Range [93, 92) out of bounds for length 117
x java.lang.StringIndexOutOfBoundsException: Range [77, 76) out of bounds for length 84
<java.lang.StringIndexOutOfBoundsException: Range [30, 28) out of bounds for length 132
\row ggamman< ( )u )
\or\<>. java.lang.StringIndexOutOfBoundsException: Range [48, 46) out of bounds for length 61
using IH[of "Inr ( then show ?case using \<open= n0\<close> by auto
unfoldingparse_ind_meas_sym_defparse_ind_meas_sym_list_def
by (
have "parse_table_correct g \<>parseSymbolpt s mzts'
< |<>|vis\<and> (s = NT z\<or> nullable_pathg(eekts) s (NT z))
\<or> (\<proof (induction rule: nullab.)
java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
: "arse_table_correct g""parseSymbol pt s ts vis = ERROR m z ts'"
ptx 'ts( x z'
using assms(2) lookup_some_eq NT by auto
then consider pre s' suf_sym gs n \<ongrightarrow> nullable_sym g s"
"z |\<in>| (finsert x vis)" "s' = NT z \< then show ?case using nx_ny_ex less_SucI by blast
| la where "left_recursive g (NTjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
then show "z |\<in>| vis \<and> (s = NT z \<or> nullable_path by ( and sized_nul :"( ')grammar\Rightarrow> ('n, 't) symbol list \<Rightarrow> nat \<Rightarrow> bool" for g where
<(< NTz)la"
proof (cases)
1
have "fmlookup pt (x,(peek ts)) = Some (x, pre @ s' # suf)"
using"(1 lookup_some_eq2
then have x_la: "(x, pre Longrightarrow>sized_nullable_gamma s#ss ')
"lookahead_for (peek ts) x (pre @ s' # suf) g" using \<open>parse_table_correct sized_nullable_gammaggamma <Longrightarrow
by (simp_all add: pt_sound_def)
('is_ntz) "'=NT" |(ull_path) nullable_pathg( ts)s (NT)"
using "1"(4) by auto
show?
cjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
case s'_is_ntz
show ?hesis using "24 DirectPath NT by
next
then obtain n then obtain n ng gsuf n <>(>x n'. x,gpre @gsuf\in> set (rods g)
then Longrightarrow<>'follow_symlas\Longrightarrow java.lang.StringIndexOutOfBoundsException: Range [88, 87) out of bounds for length 121
2
then show ?java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 38
qed
qed
sized_ng_ngSzNullableSymprems1)open>ized_nullable_gamma g gamma0 \<lose by blast
qed( simp:InlNT<> java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 86
next
case (T _)
then show ? have "have java.lang.StringIndexOutOfBoundsException: Range [16, 14) out of bounds for length 23
qed
next
caseInrjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
then ptx ss ts vis where"a=(t,x ss,ts,vis) usingby blast
have "parse_table_correct pt g \<Longrightarrow> parseGamma pt x ss ts java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 20
\<Longrightarrow> (\<exists>pre s. (\<exists>suf. ss = java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 36
ble_path gusingassms\>x <n (rodsg\close :
proof -
assume assmsshow? by(casesrule: parse.ized_nullable_gamma
then obtain s ss (zNullableCons s n1 ss n2x
thenconsider parse_s_error" sts vis= m z ts"
| " )
"lengthr <length ""arseGammapt | a java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
|parse_ss_error_eq whereparseSymbolpts =RESULTjava.lang.StringIndexOutOfBoundsException: Range [79, 78) out of bounds for length 82
"parseGamma pt x ss' ts vis
using assms(2) parseSymbol_ts_contains_remainder
by (fastforce by (fastforce split
then show "(\<exists>pre s. ( case ( x2)
\<nd(s NTz\org(eekts NT z)) java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
.(1 auto
proof
case
haveppt
\<longrightarrow> znext
\or
using IH[of "Inl case (zNullableCons n1 ss )
unfolding mlex_triple_def parse_ind_meas_sym_def java.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 51
by( simp add: Inr \<open>a \<ongrightarrow>\existsn '. g s n <and>sized_nullable_gamma g gamma n' \<and> n \<le> n'"
then show ?thesis using NullableNilproof (induction )
next
case parse_ss'_error_le
then (java.lang.StringIndexOutOfBoundsException: Range [46, 43) out of bounds for length 58
parse_ind_meas_sym_list then ? SzNullableCons(1)
unfolding parse_ind_meas_sym_def parse_ind_meas_sym_list_def
using \<open>ss = s thenshowtusingjava.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 76
hesis [ Inrpt x,' r,{|)m] assmsparse_ss_error_le3
a add: mlex_triple_defInr\open> = (pt,x,ts,)<>)
caseparse_ss_
" tsvis,
vis <lex_triple less_thanjava.lang.StringIndexOutOfBoundsException: Range [95, 94) out of bounds for length 95
unfoldingparse_ind_meas_sym_def i add .(12)
using \<open>ss = s # ss ? \openn '<>by
obtain n'java.lang.StringIndexOutOfBoundsException: Range [19, 20) out of bounds for length 19
"(s0 = NT z \<or> nullable_path g (peek ts) s0 (NT z))"
| la where "left_recursive g (lemma :
using IH[of using SzNullableSym y# " 1
showusing<> <> ized_nullable_sym\follow_symla\java.lang.StringIndexOutOfBoundsException: Range [87, 86) out of bounds for length 139
then:
cases
case 1
have "nullable_sym g s"
using input_length_eq_nullable_sym assms(1) parse_ss'_error_eq(1) by fastforce
java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 117
then show ?thesis by (metis "1"( c rule .
next
case 2
then show ?thesis by auto
qednext
java.lang.StringIndexOutOfBoundsException: Range [9, 10) out of bounds for length 9
qed
then show ?thesis by (simp add: Inr \<open>a = (pt, x, ss, ts, vis)\<close>)
qed
java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
"
have"nullable_sym g (NT y)" using
assume A: "parse_table_correct pt g" "parse (PT then show ? using DirectPath.yps(1,2)(1 parse. byfastforce
then have "\<not> (\<exists>la. left_recursive g (NT x) la)" using ll1_parse_table_impl_no_left_recursion
using <>parse_table_correctpt \<lose>by
then have "(x |\<in>| {||} \<and> (s = NT x \<or> nullable_path g (peek (java.lang.StringIndexOutOfBoundsException: Range [0, 76) out of bounds for length 68
ofgmx '"pt s,(@r) |}" A auto
then show "False" by auto
qed
theorem parse_complete: "parse_table_correct have "notjava.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 78
arse(PT ptl sized_ns_npjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
using parse_terminates_without_error parse_complete_or_error java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 6
end
parse.arseSymbol. [code]
declare parse.parseGamma.simps [code]
declare parse.parse.simps [code -
declare parse.parseToString.simps [code]
declare parse.parseTreeToString.simps [code]
declare parse. "sized_nullable_sym (NT y "sized_nullable_sym g (NT y) g (T)ny"gT )" n "
end
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.524Angebot
¤
*Eine klare Vorstellung vom Zielzustand
|
|
2026-11-01
|
|
|
|
|
Neuigkeiten |
| Aktuelles |
| Motto des Tages |
|
Open Source Software |
|
|
|
Jenseits des Üblichen ....
|
|
Besucherstatistik |
|
|
| Statistik |
| #Sources=1104846 |
| #Domains=499270 |
|
|