Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  LL1_Parser.thy   Sprache: Isabelle

 

section ‹Parser› n\a>suf  suf'"

theory LL1_Parser
  imports Parse_Table
begin


datatype ('n, 't) parse_tree = Node "'n" "('n, 't) parse_tree list" | Leaf "'t"

datatype ('n, 't, 's) return_type = RESULT "('n, 't × 's) parse_tree" "('t × 's) list"
  | ERROR "string" "'n" "('t × 's) list"
  | GRAMMAR_NOT_LL1 "string" "'t lookahead"
  | REJECT "string" "('t × 's) list"

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 × pre: pre'
  "mismatchMessage a ≡ λ(a', s).
  ''Token mismatch. Expected '' @ showT a @ '', saw '' @ showT a' @ '' ('' @ showS s @ '')''"

function (domintros) parseSymbol ::
  "('n, 't) parse_table →?cas by (cases pre') auto
and
  parseGamma ::
  "('n, 't) parse_table → 'n → ('n, 't) symbol list → ('t × 's) list → 'n fset
  → ('n, 't, 's) return_type"
  where
    "parseSymbol _ (T a) [] _ = REJECT ''input exhausted'' []"
  | "parseSymbol pt (T a) (t#ts) vis = (if fst t = a then RESULTcase (Consa pre)
    else REJECT (mismatchMessage a t) (t#ts))"
  | "parseSymbol pt (NT x) ts vis = (if x |∈| vis then 
    else (case fmlookup pt (x, peek ts) of
      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 []) ts"
   parseGamma pt nn (s#gamm') 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' → RESULT (Node n (t # tls)) r'
          | e → e))
    | e → e))"
proof (goal_cases)
  case (1 P x)
  show ?proof ( gamma)
  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
    java.lang.StringIndexOutOfBoundsException: Range [7, 8) out of bounds for length 7
  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
qedauto

definition nt_from_pt :: "('n, 't) parse_table → 'n fset" where
  "nt_from_pt pt = fst |`| fmdom pt"

definition ::
  "('n, 't) parse_table → ('n, 't) symbol → ('t × 's) list → 'n fset → nat × nat × nat" where
  "parse_ind_meas_sym pt s ts vis = (length ts, fcard (nt_from_pt pt |-| vis), 0)"

definition parse_ind_meas_sym_list ::
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
where
  "parse_ind_meas_sym_list pt ss ts vis = (length ts, fcard (nt_from_pt pt |-| vis), length s+)

definition parse_ind_meas :: "('n, 't) parse_table → ('n, 't) symbol + ('n, 't) symbol list →
    ('t × 's) list → 'n fset → nat × Ni
  "parse_ind_meas pt ss ts vis = (length ts, fcard (nt_from_pt pt |-| vis),
    (case ss of Inl ssthen show ? by auto

definition lex_triple ::
  "('a × 'a) set → (next
  where "lex_triple ra rb rc = ra <*lex

lemma in_lex_triple[simp]: "((a, b, c), (a', b', c')) ∈ lex_triple r s t
    ⟷ (a, a') ∈ r ∨ a = a' ∧ (b, b') ∈ s ∨hav ys_e: " gpres#gsuf"
  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 have"ookahead_for la x (gpre @ s # gsuf) g"
  "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))
  ==> (∧tr r. parseSymbol pt s ts vis = RESULT tr r ==> length r ≤ length ts)" and
  parseGamma_length_bound_partial:
  "parseSymbol_parseGamma_dom (Inr (pt, n, gamma, ts, vis))
  ==> (∧tr r. parseG by (simp ad:Fi FirstNT.hyps(2,) lookahead_for)
proof (induction rule: parseSymbol_parseGamma.pinduct)
  case (1 pt a vis)
  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 pt x ts vis)
  then show ?case by (auto simp add: parseSymbol.psimps(3) split: if_splits option.splits)
next
  case (4 pt n ts vis)
  then show ?case by (auto simp add: pby (simp add: FirstNT.prems(2) ys_props(2) lookahead_for_def)
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 |∉?thesisusingassmsby
  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 |∈using sss1 ysm
  then show ?thesis by (metis fcard_fminus1_less fminus_finsert)
qed

termination
proof (relation "mlex_triple (λx. case x of
      java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 5
    | Inr (pt, n, ss, ts, vis) → parse_ind_meas_sym_list  howse
  case 1
  then show ?case by (simp add: mlex_triple_def wf_lex_triple)
nextofes
  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
 henweng_deflist_defjava.lang.StringIndexOutOfBoundsException: Range [96, 94) out of bounds for length 97
      auto
next
  ase3smmas)
  then show ?case unfolding mlex_triple_def parse_ind_meas_sym_list_def parse_ind_meas_sym_def by
      auto
next
  case (4 pt s gamma' ts vis y z str r)
  then show ?case unfolding mlex_triple_def parse_ind_meas_sym_list_def parse_ind_meas_sym_def
    by (fastforce dest: parseSymbol_length_bound_partial)
qed

fun parse ::
  "('n, 't) ll1_parse_table → ('n, 't) symbol → ('t × 's) list → ('n, 't, 's) return_type"
where
  "parse (PT pt) s ts then show ?thesis using FirstNT.IH ‹nullable_sym g s› by auto
| "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
  "concatWithSep [] [] = []"
| " [] acc= cc"
| "concatWithSep s [] = s"
| "concatWithSep s (c # acc) = (if c = CHR '' '' then s @ c # acc else s @ '' '' @ c # acc qed

fun parseTreeToString :: "('n, 't × 's) parse_treeed
  "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 ≤ <ble_sym le_imp_less_Suc by
  "parseToString (PT pt) s ts = (case parseSymbol pt s ts {||} of
    RESULT t [] →
| " EAMB_LArjava.lang.StringIndexOutOfBoundsException: Range [68, 66) out of bounds for length 99
    (case l of thjava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 42

subsection ‹

  sym_derives_p from DirectPathhyps(4)cnidr(ftgma fist_lagma"
 "('n, 't) grammar →| (nul "nal_gamma g ama""fll_sym g a(
 →
java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 17
java.lang.StringIndexOutOfBoundsException: Range [87, 86) out of bounds for length 111
 
 T_sdp: "sym_deri then have "¬ follow_sym g la (NT x)" using DirectPath.prems(1,2) by
  NT_sdp: "(x, gamma) ∈ set (prods g) ==> lookahead_for (peek (w @ r)) x gamma g
 ==>then show ?thesis using DirectPath.prems(3) by auto
  Nil_gdp: "gamma_derives_prefix g x [] [] (Node x []) r"
  Cons_gdp: "sym_derives_prefix g s wpre v (wsuf @ r)
 ==>
 ==>

  parseSymbol_ts_con(NT y)" using DirectPath.hyps(2) null_gamma(1) nullable_sym_in by fastforce
 "∧t r. parseSyusing DirectPath.hyps(1,2) null_gamma(1) parse.sized_ns_np by fastforce
 parseGamma_ts_contains_remainder:
 "∧t qed
  (induction pt s ts vis and pt n gamma ts vis rule: parseSymbol_parseGamma.induct)
 case (5 pt n s gamma' ts vis)
 nshw cas y(fastforc pit:turn_tyeslitspaste.split pion.slt f_slt)
  (auto split: return_type.splits parse_tree.splits option.splits if_splits)

  parse_meas_induct: case (IndiretPahxgmaggr az
 assumes "∧y. (∧gaa
 ,s s i)\Rightarrow>pase_indmssmp svs
 | Inr (pt, x, ss, ts, vis) →unfo lookahefr_df b ato
 shows "P z"
java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 13
 wee r= lx_ripl \>x asex f
 Inl (pt, s, ts, vis) → parse_ind_meas_sym pt s ts then ae"first_sym g lTx) sngIdePt.ys1FisTb ae t
 | Inr (pt, x, ss, ts, vis) \<Rightarrow  follow_sym g la (NT x)" usingIdtPath.pres((, y
 simp add: mlex_triple_def wf_lex_triple)

java.lang.StringIndexOutOfBoundsException: Range [0, 77) out of bounds for length 57
 "parseGamma pt x gamma ts vis = RESULcas ulgm
  (induction pt s ts vis and pt x gamma ts vis arbitrary: and v r
java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 40
 case (5 pt n s' gamma' ts vis)
 obtain a b whehave "nullable_ga g gsuf"
    using 5(2,3) by (auto split: return_type.splits       using null_gamma(1) IndirectPath.hyps(2) nullable_split[
"]
  ?
  proof (cases gamma')
    case Nil
    then  "parseGamma   gamma'b if b  <length ts then {}else vis)
        = RESULT (Node n []) b"
      by auto
    then show ?thesis using 5(3) A
      (uto:..plits
  next
    case (Cons x'' gamma'')
 ls "v=Noden "  523  by
        (auto split: return_type.splits parse_tree.splits)
    show?hesis by java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29

qed auto

parseSymbol_parseGamma_sound c x ofInl(,s ts )\Rightarrow  ptg
  \<longrightarrow> parseSymbol pt s ts vis = RESULT v r \<longrightarrow> (\<exists>w. w @ r = ts \<and> sym_derives_prefix g s w v r)
    pt ,gamma , <> g
  \<longrightarrow> (parseGamma pt n gamma ts vis = RESULT v r
  \<longrightarrow> (\<exists>w.         auto
proof (induction  qed
  case (1 y)
  note IH = "1"
  {
    
    assume A: "y = Inl (pt, slemma : "ullable_pathgla( x)y
        "parseSymbol pt s ts vis = RESULT v r"
    consider (T) a lex ts'  \Longrightarrow>\existsgamma. (x, gamma) \<in> set (prods g) \<and> lookahead_for la x gamma g"
      |   by (asesrule .cases 
        "parseSymbol pt s ts vis = java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 0
      using A( assumes parse_table_correcttbl( :(n tgrammar"
    then have "\<exists>w. w @ r =   "<> left_recursive N x)la"
    proof cases
      case T
      then show ?thesis by (auto simpproof
    next
      case NT
 "(nrp, x,ss,ts,(finsert x), y)\in 
        (\<lambda>x. case x of Inl (pt, s, ts, vis) \<  then obtain gamma where "(x, gamma) \<in> set (prods g)" xgammag"
 x,ss , <> pt vis"
        unfolding mlex_triple_def parse_ind_meas_sym_def parse_ind_meas_sym_list_def
        using A(1   consider" gla " |"nullable_gamma g""   (x)"
      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
show ?hesis  A2) NT(,) NT_sdp pt_sound_def by fastforce
    qed
  }
   proof (ases
  {
    fix pt x ss ts vis
    assumeA " = Inr (pt, x ss,ts,vis)" "arse_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'"      "irst_symgla (x"  \open>x, gamma) <> set  g)<>by( 
        "parseSymbol pt s ts vis =     then obtainnx ny  "sized_first_sym  la (T) nx "ized_first_sym g la (NT x ny"
        "parseGamma pt x ss' r1 {||} = RESULT (Node x tls) r" "v = Node x (t # tls)"
sEqs ss   where"s= #ss'""arseSymbol  sts  =RESULT t "
        "parseGamma pt x ss' ts vis = RESULT (Node x     then have "ny = nx" using assms sized_first_sym_det by
    proof (cases ss)    then show ?hesis using <> <nxclose> by auto
      case Nil
      then show ?thesis by (simp add: that(1))
    next
      case (Cons s ss')
      thenshow thesis
        using parseSymbol_ts_contains_remainder parseGamma_node(2) A(3)
        by (fastforce simp: ConsLe ConsEq split: return_type.splits     obtain n 'where "sized_nullable_symg( x)n sized_nullable_sym  ( x)n' "n <java.lang.StringIndexOutOfBoundsException: Index 100 out of bounds for length 100
    qed
    then have "\<exists>w. w @ r = ts \<and> 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  qed
        ()parseSymbol_ts_contains_remainder(2)
        by metis
      
        using IH[of lemma : " x ofInl(t s,ts,vis)\<Rightarrow> parse_table_correct pt g
        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)\<>parseSymbol  s  vis=RESULT v  \>length    ts <> nullable_sym g s
        using IH[of "Inl (pt, s, ts, vis)"] \<open>ts = wpre @ wsuf    (,x, , <> java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 124
        unfolding mlex_triple_def parse_ind_meas_sym_def parse_ind_meas_sym_list_def
by( add ()
      ultimately show ?thesis by (simp add: ConsLe(1,5) Cons_gdp \<open>ts = wpre @ wsuf @ r\<close> case1y
    next
   case
      obtain w where    ( )
          fastforce
      have "length ss' < length ss"     obtainpt ts viswhere a=(t ,)   )auto
      then have     "java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 54
usingof" pt,ss,ts " (,)(java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
        unfolding ()
        by (auto simpcase (Txjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
 "g  ]t "
        using IH[of "Inl (pt, s, ts, vis)"] \<open>ts = w @ r\<close> 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 \<open>ts = w @ r\<close> 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 \<Longrightarrow> parse (PT pt) s (w @ r) = RESULT v r
  \<Longrightarrow> 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
    \<Longrightarrow> (\<forall>vis. (\<exists>m x ts'. parseSymbol pt s (w @ r) vis = ERROR m x ts')
    \<or> (parseSymbol pt s (w @ r) vis = RESULT v r))"
    and "gamma_derives_prefix g y ss w v r
     \<Longrightarrow> (\<forall>vis. (\<exists>m x ts'. parseGamma pt y ss (w @ r) vis = ERROR m x ts')
    \<or> (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 "(\<exists>m y ts'. parseSymbol pt (NT x) (w @ r) vis = ERROR m y ts')
    \<or> parseSymbol pt (NT x) (w @ r) vis = RESULT v r" for vis
  proof (cases "x |\<in>| 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 \<open>fmlookup pt (x, peek (w @ r)) = Some (x, gamma)\<close> 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 "(\<exists>m x ts'. parseGamma pt n (s # ss) ((wpre @ wsuf) @ r) vis = ERROR m x ts')
    \<or> parseGamma pt n (s # ss) ((wpre @ wsuf) @ r) vis = RESULT (Node n (v # vs)) r" for vis
  proof -
    have "\<exists>m x ts'. parseSymbol pt s (wpre @ wsuf @ r) vis = ERROR m x ts'
      \<or> parseSymbol pt s (wpre @ wsuf @ r) vis = RESULT v (wsuf @ r)" using Cons_gdp.IH(2) by auto
    moreover have "\<exists>m x ts'. parseGamma pt n ss (wsuf @ r) vis = ERROR m x ts'
      \<or> parseGamma pt n ss (wsuf @ r) vis = RESULT (Node n vs) r" using Cons_gdp(4) by auto
    moreover have "\<exists>m x ts'. parseGamma pt n ss (wsuf @ r) {||} = ERROR m x ts'
      \<or> 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 \<Longrightarrow> sym_derives_prefix g s w v r
  \<Longrightarrow> \<exists>m x ts'. parse (PT pt) s (w @ r) = ERROR m x ts'
  \<or> (parse (PT pt) s (w @ r) = RESULT v r)"
  using parseSymbol_parseGamma_complete_or_error by fastforce


subsection \<open>Error-free Termination\<close>

inductive sized_first_sym :: "('n, 't) grammar \<Rightarrow> 't lookahead \<Rightarrow> ('n, 't) symbol \<Rightarrow> nat \<Rightarrow> bool"
  for g where
    SzFirstT: "sized_first_sym g (LA y) (T y) 0        by auto simp:  :if_splits .splitsjava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
  | SzFirstNT: "(x, gpre @ s # gsuf) \<         fcard_diff_insert_less parse_ss_simp(1,2 by fastforce
    \java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 64

lemma first_sym_exists_size         mlex_triple_defjava.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 84
  using SzFirstT SzFirstNT
  by -(induction rule: first_sym.induct; fastforce)

lemma sized_fs_fs: "sized_first_sym g la s n \<Longrightarrow> first_sym g la s"
  by (induction rule: sized_first_sym.induct) ( t

medial:"pre  s  suf '@s'# suf'
    \<Longrightarrow> s \<in> set pre'\<or> s' \<inby (cases ts auto   split: if_splits optionsplits)
proof (induction pre arbitrary: pre')
  case Nil
  then show ?case by (cases pre') auto
next
  case (then show ?thesis by simp
  then show ?case by (cases pre') auto
qed

lemma nullable_sym_in:     qed
proof (induction gamma)
  case (Cons s    show?thesis by (simp:Inl \<open> = (, s,ts,vis)<close>
  have "nullable_gamma g gamma" using Cons  
  moreover have "nullable_sym g s'" using     Inr a)
  ultimately show ?case       ptxsstsvis where " =(, x,ss, ts, " (ases y) auto
qed simp

lemma nullable_split: "nullable_gamma g (xs @ ys) \<Longrightarrow> 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 \<Longrightarrow> nullable_gamma g xs \<Longrightarrow> 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 \<open>nullable_gamma g xs'\<close>)
  then show ?case using FirstGamma[where gpre = "s # xs'" and s = s' and gsuf = "ys'"] by
      (simp add: \<open>first_sym g la s'\<close> \<open>xs @ ys = xs' @ s' # ys'\<close>)
qed

lemma follow_pre: "(x, pre @ suf) \<in> set (prods g) \<Longrightarrow> s \<in> set pre \<Longrightarrow> nullable_gamma g pre
  \<Longrightarrow> first_gamma g la suf \<Longrightarrow> 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      then show ? by simp add:NullableNil
  qed
qed

lemma no_first_follow_conflicts:
  assumes "parse_table_correct tbl g"
  shows "first_sym g la s \<Longrightarrow>         "parseGamma pt x ss' ts vis = RESULT (Node)r"v    v1"v   v  )"

proof   then show ?ase by(auto,cases rule         ( split: return_type.parse_treeif_splits
  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) \<in> set (prods g)" "nullable_gamma g ys" by      proofcases
      cases auto
  have ys_eq: "ys = gpre @ s # gsuf"
  java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
    have "ookahead_forla (gpre    "
      by (simp add: FirstGamma FirstNT.hyps(2,3) lookahead_for_def)
    moreover have "ookahead_for  ys g"
      by (simp add: FirstNT.prems(2) ys_props(2) lookahead_for_def)
    ultimately show ?thesis using assms by
        (           ( simp add: Inr\<pena =(t x,ss ts,vis)<>)
  qed
  have "nullable_sym g s" using ys_props(2) ys_eq nullable_sym_in by fastforce
  thenshow?ase
  proof (cases s)
 (NT)
    have "nullable_gamma g gsuf" using nullable_split[where xs = "gpre @ [s]"           parse_ind_meas_sym_def
        auto
    then have "follow_sym g la s" using FirstNTjava.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
      thesisusing FirstNT.IH\opennullable_sym g s\<close> by auto
  next
    case (T t)
    show ?thesis using \<open>  have "s' = NT x \<longrightarrow>      
  qed
qed

lemmafirst_sym_rhs_eqsparse_table_correcttg\Longrightarrow   s#suf <in setg
  \<Longrightarrow> (x, pre ed
  <Longrightarrow>first_symg  java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 7
()
  case
  have "pre @ s # suf = pre' @ s' # suf'"  qed
  java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    moreover have "lookahead_for la x (pre' @ s' # suf') g" by
        (simp add: "1"(5,7) FirstGamma lookahead_for_def)
     ?
      using "1"(1-3) unfolding pt_complete_def by (metis Pair_inject option.inject)
  qed
  then     Inl (pt,, )  
    | (eq) "pre      <>( \java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 25
  then show ?case
  proof cases
    java.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 3
    then have "nullable_sym    Inr(, x, , vis)\Rightarrow> pt \longrightarrow>
    moreover have "follow_sym g la s"
    java.lang.StringIndexOutOfBoundsException: Range [9, 5) out of bounds for length 84
      have "first_gamma g a g pre \>z \|vis  <>(=  <>  peekts       >\ . g  > g  \>ny<"
          auto
       show?using1(3,)s_in_pre follow_presuf="'#suf' by java.lang.StringIndexOutOfBoundsException: Index 92 out of bounds for length 92
    qed
     show? using1(1,6)no_first_follow_conflicts

    case scase(1java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
thenjava.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 76
    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 obtain java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 83
    qed
"7 auto
  next
    case eq
then? blast
  qed
qed

lemma sized_first_sym_det:
  assumes p "
  \Longrightarrow> (\<forall>n'. s = s' \<longrightarrow> sized_first_sym g la s' n' \<longrightarrow>         fastforce
proof (induction arbitrary:      then show?thesis
  case (SzFirstT g y)
  java.lang.StringIndexOutOfBoundsException: Range [11, 6) out of bounds for length 67
next
  case (SzFirstNT x pre s q
   "    <  gs''<>Suc n n"forn
  (impI java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 32
     1
    obtain gpre java.lang.StringIndexOutOfBoundsException: Range [0, 20) out of bounds for length 0
      "nullable_gammag  "sized_first_symgla s0n0 row>',') > nat \> bool
      using 1(1) by (cases rule: sized_first_sym.cases[OF 1(  and  :  "'t \            \<Longrightarrow> parseGamma pt x ss' ts (finsert z
then"           Lngrightarrow>(\<>pre s suf.ss = pre @ s  suf\and>nullable_gamma g pre \<and> z |\<in>| (finsert x vis)
    then have "s = s0"            \and> g \ongrightarrow  T)( n"
    then have            <> (existsla left_recursive g (NT z) la))"
>n'  Suc java.lang.StringIndexOutOfBoundsException: Range [46, 44) out of bounds for length 60
  qed
  then          unfolding mlex_triple_def  parse_ind_meas_sym_list_def
qed

lemma sized_first_sym_np: "nullable_path g la x y \<        have "parse_table_correct pt g \<Longrightarrow> parseSymbolptg <Longrightarrow    ts vis= ERROR  z ts'
    \<Longrightarrow>\<ongrightarrow>z|<n   or  ( java.lang.StringIndexOutOfBoundsException: Range [90, 89) out of bounds for length 100
le_pathinduct)
  case (DirectPath x gamma g gpre z gsuf la)
        proof -
then g ( )(ucn"DirectPathhyps  sadd SzFirstNT
  then           assume assms:" pt  java.lang.StringIndexOutOfBoundsException: Range [67, 66) out of bounds for length 92
next
            have"parseGamma  x ss ts finsert vis)=ERROR m  ts'
  then obtain nx ny 
    "sized_first_sym g la (NT y) nx \<and> sized_first_sym g la (NT z) ny \<and> ny < nx" by auto
  then have "sized_first_sym g la (NT x) (Suc nx)" using IndirectPath.hyps by (simp add: SzFirstNT)
thenjava.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 51
qed

inductive sized_nullable_sym :: "('n, 't) grammar \<Rightarrow> ('n, 't) symbol \<Rightarrow> nat \<Rightarrow> bool"
lable_gamma:  (, java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 133
  SzNullableSym: "(x, gamma) \<in> set (prods g)
    \<Longrightarrow> sized_nullable_gamma g gamma n \<Longrightarrow> sized_nullable_sym g(auto             >(\>.java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 60
| SzNullableNil: "sized_nullable_gammacase java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
| SzNullableCons: "sized_nullable_sym g s n \<Longrightarrow> lemma ng_sized_ng:"               "1java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 53
    \<Longrightarrow g( #)(n+n')

lemma sized_ng_ng: "sized_nullable_sym g s n \<Longrightarrow> nullable_sym g s"
"sized_nullable_gamma  n\  using SzNullableSym SzNullableNil SzNullableCons
  by (induction
    (consider(')s   z" |("  peekts '( zjava.lang.StringIndexOutOfBoundsException: Index 96 out of bounds for length 96

lemma ng_sized_ng: "nullable_sym g s \<Longrightarrow> \<existsthen  ?hesis
  "proof(ases)
  using lemma sized_nullable_':
  by (induction rule: nullable_sym_nullable_gamma.inducts) fastforce+

   then show ?hesis "1(-) DirectPathx_la fastforce
  assumes"parse_table_correct pt g"
  shows "sized_nullable_sym g s n
    \<Longrightarrow> (\<And>n'. follow_sym g la s \ casenull_path
 n\Longrightarrow \<Andgpre.(,@) <>setpg)
    \<Longrightarrow> follow_sym g la (NT x) \<Longrightarrow               <>(n.  <  ' \<  n)
proof (induction rule: sized_nullable_sym_sized_nullable_gamma            qed
  case (SzNullableSym xnext
         case 2
                show?hesis by blast
have "amma0=gamma"
  proof -
    have "lookahead_for la x gamma0        
     using sized_ng_ng .(1 \<opens n0<>byblast
    then have lookup_1:       auto add   \opena=   2  where(,gamma0 \> (prodsg"
      using assms \<open> "sized_nullable_gamma g  " n  n0by()
   have " java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 23
      using sized_ng_ng SzNullableSym.prems(1) SzNullableSym.IH(2) by blast
    then have lookup_2: "fmlookup pt     ( a)
      by (auto simp add: pt_complete_def)
    show ? obtain  ss  vis "  ( ,ss,ts )  prod_cases5  blast
  qed
  then have "n0 = n"
    using \<open>    then have lookup_1: "fmlookup pt  )= x gamma0"
      SzNullableSym.prems(1) by auto
  then show ?case by (simp add: \<          \<and> (s = NT z \<or> nulla       java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 100
next
case
  then  ?aseby (cases : parse..cases)auto
next
case( s n1 n2 )
  from SzNullableCons.prems(3)        () "arseSymbolpt  visvis = ERROR m ts'java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
    "sized_nullable_sym g s n1'" "sized_nullable_gamma g ss n2'" "n' = n1' + n2'"           "  < ts p xss'r{|      utoadd:t_complete_def)
      showshow ?        (_error_eqstr "   tsvis  RESULT str ts"
  proof (cases s)

      qed
    then show ?thesis using FollowLeft NT SzNullableCons.prems(1,2) by fastforce
  next
T
     \opensized_nullable_symg         <nd    \or>nullable_path p )s( z) <or>
  qed
  then have "n1 = n1        SzNullableSymprems) by auto
  moreover have "n2 = n2      proof cases
using SzNullableCons.(4)[of  "gpre  s"'\sg  '<>
    by (simp add: SzNullableCons.prems(1,2))
  ultimately show ?case using \<open>n' = n1' + n2'\<close> by auto
qed


  assumes"parse_table_correct t g"
  shows "sized_nullable_sym g s n \<Longrightarrow> follow_sym g la s             <> (\<exists>la. left_recursive g (NT z) la)"
  using sized_nullable_sym_det' assms by blast

lemma sym_in_gamma_size_le: "nullable_gamma g gamma \<Longrightarrow> s \<in> set gamma
  < <> n sized_nullable_symsn\ java.lang.StringIndexOutOfBoundsException: Range [88, 87) out of bounds for length 117
 inductiongamma
    proof ( s)
  then show ?case by auto
next
  case Consa )
  from Cons.prems(1) have         have"parse_ind_meas_sym_list pt ss' r {||},
    (cases rule: nullable_gamma.cases, auto)+
     showhesisusingFollowLeftNT java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 80
  proof (cases   next
    case True
      ?hesis using SzNullableCons nullable ng_sized_ng by fastforce
  next
    case False
    then show ?thesis using Cons.IH    from \open>sized_nullable_sym        then show ?hesisusingIHof" (, ,r |"z parse_ss()
               by (utosimp :   <> = ,, ss,ts,vis\close)
  qednext
qed

lemma sized_ns_np:have "parse_ind_meas_sym_listpt ss'  
  assumes "(x, pre     using  pt ss ts )\n lex_triple   "
    "nullable_sym g (NT y)"
  shows "\<exists>nx ny. sized_nullable_sym g (NT x) nx \<and> sized_nullable_sym g (NT y)               ( java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 44
proof -
   n'where
    "sized_nullable_sym g (NT y) n" "sized_nullable_gamma g (pre @ NT y # suf) n'" "n \<le> 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')"
    java.lang.StringIndexOutOfBoundsException: Range [29, 9) out of bounds for length 74
  then show ?thesis  \<penn\le shows"     \> g   \>sized_nullable_sym g  '\Longrightarrow n ="
qed

lemma exist_decreasing_nullable_sym_sizes_in_null_path:
  shows "nullable_path g la x  proof cases
    \<Longrightarrow> follow_sym g la x
\java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 112
proof (induction rule: nullable_path.induct)
  case\Longrightarrow <existsnn. sized_nullable_sym g s n\<and sized_nullable_gamma g gamman'<>n <e>n'
  from DirectPath.prems(2) obtain ys where "(x, ys) \<in>proof(inductiongamma)
      (ases :nullable_symcases)auto
  from DirectPath.hyps(4) consider (fst_gamma) "first_gamma g java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 12
      then ? by auto
    unfolding lookahead_for_def by auto
  then show ?case
  proof cases      qed
  case 
    then have "first_sym g la   Consprems1)have : "java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 7
thenhave"<ot follow_sym  la(NT     then have "\<not> follow_sym g la (NT x
      (auto simp add: no_first_follow_conflicts)
    then show ?thesis using DirectPath.prems(3) by auto
  next
    case   proof (cases "a ="
   java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 100
showthesis.12 null_gamma)sized_ns_np 
  qed
next
  case (IndirectPath x\open ptg<  fastforce
  from IndirectPath.hyps(4) consider (fst_gamma) "first_gamma g la gamma"
    |     thenshow ?hesis using.IHCons.prems(2)SzNullableCons nullable ng_sized_ng(1) by
    unfolding r_conditions[   x ts Inl (pt,,(w  r,{|})]A by auto
  then show ?case
  proof cases
    case fst_gamma
    then have "first_sym g la (NT x)" using IndirectPath.hyps(1) FirstNT by cases auto
    then "<> follow_sym g la (NT x)" using IndirectPath.prems(1,2) by
        (auto simp add: no_first_follow_conflicts)
    then show ?thesis PTptemmajava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
  next
    casejava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
    have "nullable_sym     "nullable_sym g (NT )"
        fastforce
    have "nullable_gamma g gsuf"
      using null_gamma(1) IndirectPath.hyps(2) nullable_split[where xs = "gpre @ [NT y]"] by auto
    then have "follow_sym g la (NT y)" using null_gamma IndirectPath.hyps(1,2) by
        (auto  obtain n 'where
    then obtain ny nz where
"sized_nullable_sym y "sized_nullable_sym(T""<"
      using IndirectPath.IH IndirectPath.prems(1) \<open>nullable_sym g (NT y)\<close> by auto
    obtain nx ny' where
      "sized_nullable_sym g (NT x) nx" "sized_nullable_sym g (NT y) ny'" "ny' < nx"
      using IndirectPath.hyps(1,2) null_gamma(1) sized_ns_np \<open>nullable_sym g (NT y)\<close> by fastforce
    then have "     SzNullableSymwhere  = pre@NTsuf" assms1)auto
        \<open>sized_nullable_sym g (NT y) ny\<  then show thesisusing <open>\>n'c o> g(  \close java.lang.StringIndexOutOfBoundsException: Range [113, 112) out of bounds for length 121
    then java.lang.StringIndexOutOfBoundsException: Range [0, 13) out of bounds for length 0
    then show ?thesis  using \<open>sized_nullable_sym g (NT x) nx\<  shows "nullable_path g la x y \<Longrightarrow> parse_table_correct t gjava.lang.StringIndexOutOfBoundsException: Range [105, 104) out of bounds for length 108
        auto
  
qed

lemma proof (induction rule:.java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
  \<Longrightarrow> \<exists>gamma. (x, gamma) \<in> set (prods g) \<and> lookahead_for la x gamma g"
   (ases .)auto

rse_table_impl_no_left_recursion:
  assumes "parse_table_correct tbl (g :: ('n, 't) grammar)"
  shows "\<not> left_recursive g (NT x) la"
proof
  assume x_left_rec: "left_recursive g (NT x) la"
then  where"x,gamma <>set prods )""ookahead_for la x gamma "
    using nullable_path_exists_production by fastforce
  then consider "first_gamma g    unfolding  by 
    by (auto simp: lookahead_for_def)
  thenshow "alse"
  proof (cases)
    case 1
    then have "first_sym g la (NT x)" using FirstNT \<open>(x, gamma) \<in> set (prods g)\<close> by (cases) auto
    then obtain nx ny     then have "first_sym g  NT)"using .yps) FirstNT by cases auto
      "ny < nx" using sized_first_sym_np x_left_rec by blast
    then have "ny = nx" using assms sized_first_sym_det by fastforce
    then show ?thesis using \<open>ny < nx\<close> by auto
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
    2
    then have "nullable_sym g (NT x)" using \<open>(x, gamma) \<in> set (prods g)\<close> by
        (auto simp add: NullableSym)
    then obtain n n' where "sized_nullable_sym g (NT x) n" "sized_nullable_sym g (NT x) n'" "n' <have"g( y)"usingDirectPath1   
      using "2"(2)      showt  DirectPath.12 ()parsejava.lang.StringIndexOutOfBoundsException: Range [81, 80) out of bounds for length 93
    then
  qed
qed

lemma input_length_lt_or_nullable_sym: "case x of Inl (pt, s, ts, vis) \<Rightarrow> parse_table_correct pt g
    \<longrightarrow> parseSymbol pt s ts vis = RESULT v r \<longrightarrow> length r < length ts \<or> nullable_sym java.lang.StringIndexOutOfBoundsException: Index 117 out of bounds for length 68
   Inr(t, ,ts,vis)\Rightarrow pt <longrightarrow  pt   ts vis=RESULT v 
    <>lengthr<  \or> g ss"
proof (induction arbitrary: v r rule: parse_meas_induct)
  case (1 y)
  note IH = 1
  show c
  proof (cases then < java.lang.StringIndexOutOfBoundsException: Range [34, 32) out of bounds for length 78
casea
    then obtain pt s? java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 57
      
      if "parseSymbol pt s ts      
    proof      nullable_sym g( ) java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 92
      case (fastforce
      from that obtain ss where parse_ss_simp: "x |\<notin>|     "nullable_gamma ggsuf"
        "parseGamma pt x       null_gamma) .(w xs  NT"byjava.lang.StringIndexOutOfBoundsException: Index 97 out of bounds for length 97
        by (auto simp: NT split: if_splits option.splits)
      then have "(x, ss) \<in> set (prods g)" using that(2) by (auto simp add: pt_sound_def)
      have       "ized_nullable_symg NT sg N  "n< java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
          java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 68
      then have "length    obtain nx 'where
        using IH[of "Inr (pt, x, ss, ts, finsert x vis)"] parse_ss_simp(3)
        unfolding mlex_triple_def parse_ind_meas_sym_def parse_ind_meas_sym_list_def
        by (auto simp: Inl \<open>a = (pt, s, ts, vis)\<close> that(2))
show  \>xss <> g\  
    next
      case (T t    thenhave "y = ny' .1 <follow_symgla N )<>
         swhere"  t )#"
havenz   \openny nx<lose><><ny< by java.lang.StringIndexOutOfBoundsException: Index 84 out of bounds for length 84
       show?bysimp
    qed
    then show ?thesis by (simp add: Inl \<open>a = (pt, s, ts, vis)\<close>)
  next
    case (Inr a)
    then obtain pt x ss ts vis where "a = (pt, x, ss, ts, vis)" by (cases y) auto
    have "length r < length ts \<or> nullable_gamma g ss" if
p pt ss vis=vr pjava.lang.StringIndexOutOfBoundsException: Range [71, 67) out of bounds for length 73
    proof(casesss)
      case Nil
      then show ?thesis by (simp add: NullableNil)
    next
      case (Cons s ss')
      fromassumes "  :(n t )"
 xtsvis  (ode x v1)r " =Node (v0 #v1"
      | v0 v1 r0 where "parseSymbol pt s ts vis = RESULT v0 r0" "length r0 < length ts"
        "parseGamma pt x ss' r0 {  assume x_left_rec:"left_recursive g ( x la"
        using parseSymbol_ts_contains_remainder[of pt s ts vis] Cons  "  <n>set  g""lookahead_forlaxgammag
        by (fastforce split:     using nullable_path_exists_production byfastforce
       ?hesis
      proof cases
        case 1
        then have "length ts < length ts \<or> nullable_sym java.lang.StringIndexOutOfBoundsException: Range [0, 61) out of bounds for length 10
          using IH[of "Inl (pt, s, ts, vis)"] that(2)
unfoldingmlex_triple_def 
          by (auto simp add: Inr \<open>a = (pt, x, ss, ts, vis)\<close>)
        moreover have "length r < length ts \<or> nullable_gamma g ss'"
          using IH[of "Inr (pt, x, ss', ts, vis)"] that(2) 1
          unfolding mlex_triple_def parse_ind_meas_sym_def parse_ind_meas_sym_list_def
          by (auto    case 2
        ultimately show ?thesis using NullableCons Cons by blast
      
        case 2
        have "length r \<le> length r0" using parseGamma_ts_contains_remainder "2"(3) by fastforce
        then show ?thesis using "2"(2) by auto
      qed
    
    then show ?thesis by 
  qed
qed

lemma input_length_eq_nullable_sym:
  "parse_table_correct tbl g \<Longrightarrow> parseSymbol tbl s ts vis = RESULT v ts \<Longrightarrow> nullable_sym g    <  pt     vr\ljava.lang.StringIndexOutOfBoundsException: Range [76, 75) out of bounds for length 120
  using input_length_lt_or_nullable_sym[

lemmaproof (java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 56
    Inl (pt, s, ts, vis) \<Rightarrow> parse_table_correct pt g \<longrightarrow> parseSymbol java.lang.StringIndexOutOfBoundsException: Index 96 out of bounds for length 13
( \in> vis\<and(=NT  (  ( )
      \<or> (\<exists>la. left_recursive g (NT z) la))
  | Inr (pt, x, ss, ts, vis) \<Rightarrow> parse_table_correct pt g \<longrightarrow>
      parseGamma pt x ss ts vis = ERROR m z ts' \<longrightarrow> (\<exists>pre s suf. ss = pre @ s # suf
      \<and> nullable_gamma g pre \<and> z |\<in>| vis \<and> (s = NT z \<or> nullable_path g (peek ts) s (NT z)))
      \<or> (\<exists>la. (left_recursive g (NT z) la))"
java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 60
  have" r <length ts \or>  g "
  note IH = "1"
java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 17
  proof (casescasesjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
    case (Inl a)
     obtain pt ts viswhere" =(t,s ts ) usingprod_cases4by 
    then show ?thesis
    proof  "parseGamma pt x ss ts (finsert x vis) = RESULT v r"
      case (NT x)
      consider (x_in_vis) "x |\<in>| vis" | (lookup_none        by (auto simp: NT : if_splits option.splits)
         ()x'  "x \<>|vis"" <> x'"
          "fmlookup pt (x, peek ts) = Some (x',ss')"
        | (      have "fcard nt_from_pt pt |- finsert x ) <fcard (t_from_pt  || vis)
        by fastforce
      then show ?thesis
      proof (cases)
        case lookup_some_eq
        then have "fcard (nt_from_pt pt |-| finsert x vis) < fcard (nt_from_pt pt |-| vis)"
          using fcard_diff_insert_less[of x] by auto
        then have IH': "parse_table_correct pt g
            \<Longrightarrowusing [ I ( x,ss ts, finsert xvis)" parse_ss_simp(3)
            \<Longrightarrow> ((\<mlex_triple_def parse_ind_meas_sym_def
            \<and> (s = NT z \<or> nullable_path g (peek ts) s (NT z)))
            \<or> (\<exists>la. left_recursive g (NT z) la))"
          using IH[of "Inr (pt, x, ss', ts, (finsert x vis))" m z ts']
          unfolding mlex_triple_def parse_ind_meas_sym_def parse_ind_meas_sym_list_def
          by (auto simp add: Inl \<open>a = (pt, s, ts, vis)\<close>)
        have "parse_table_correct pt       from that  s  "ts=(,s  
          \<Longrightarrow> z |\<in>| vis \<and> (s = NT z \<or> nullable_path g (peek ts) s (NT z))
              \<or> (\<exists>la. left_recursive g (NT z) la)"
        proof -
          assume assms: "parse_table_correct pt g" "parseSymbol pt s ts vis = ERROR m z ts'"
          have "parseGamma pt x ss' ts (finsert x vis) = ERROR m z ts'"
            using assms(2) lookup_some_eq NT by auto
          then consider pre s' suf where "ss' = pre @ s' # suf" "nullable_gamma g pre"
            "z |\<in>| (finsert x vis)" "s' = NT z \<    then obtain pt x ss ts vis where "a = (pt, x, ss, t vis) by  )
           where "left_recursive g (T )"usingIH assms(2 auto
          then show "z |\<in>| vis \<and> (s = NT z \<or> nullable_path g (peek ts) "parseGamma pt  ts    r" "parse_table_correctpt g"
            \<or> (\<exists>la. left_recursive g (NT z) la)"
          proof (cases)
            case 1
            have "fmlookup pt (x,(peek ts)) = Some (x, pre @ s' # suf)"
               show ?thesis:java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 50
            then have x_la: "(x, pre @ s' # suf) \<in> set (prods g)"
              "java.lang.StringIndexOutOfBoundsException: Range [34, 28) out of bounds for length 106
              by (simp_all add: pt_sound_def)
            consider (s'_is_ntz) "s' = NT z" | (null_path) "nullable_path g (peek ts) s' (NT z)"
              using "1"(4) by auto
            then show ?thesis
            proof (cases)
               _
              then show ?thesis using "1"(2-4) DirectPath NT  x_la by fastforce
            next
              case null_path
              then obtain n n' where "s' = NT n" "NT x = NT n'" by cases auto
               show ?thesis""23  x_la  fastforce
            qed
          next
            case 2
            then show ?thesis by blast
          qed
        qed
        then show ?thesis by (simp add: Inl \<open>a = (pt, s, ts, vis)\<close>)
      qed (auto simp add: Inl NT \<open>a  (t, ,ss , vis)\close>
    next
      case (T _)
      then show ?thesis using Inl T \<open>a = (pt, susing IHofInr(  , " 2 java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
    
  next
    case(ajava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
    then obtain pt x ss ts vis where "a =        2
       <>parseGammax tsvis=ERRORm '
      \<Longrightarrow> (\<exists>pre s. (\<exists>suf. ss = pre @ s # suf) \<and> nullable_gamma g pre \<and> z |\<in>| vis
          >= z\or nullable_path)sNTz) <>(<>. g ) la"
    java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
       assms:parse_table_correct pt"" pt x sstsvis=ERRORmz ts'
      then obtain s ss' where "ss = s # ss'" by (auto elim:  qed
      then consider (parse_s_error
        | (parse_ss'_error_le) str r where "parseSymbol pt s ts vis = RESULT str r"
           ts  ptx ' |}=ERROR m ts"
        | (parse_ss'_error_eq) str where "parseSymbol pt s ts vis = RESULT str ts"
          "parseGamma pt x ss' ts vis = ERROR m z ts'"
        [where ="nl (,s, ts,vis)"]byauto
        by (fastforce split: return_type.splits if_splits parse_tree.splits)
      then show "(\<exists>pre s. (\<exists>suf.lemma error_conditions case  of
        \<and> (s = NT z \Inl(,,ts,vis) <>  ptg \longrightarrowparseSymbol s vis =ERROR  '
        (\<exists>la. left_recursive g (NT z) la)"\<ongrightarrow (z \in>  \> =z <> nullable_path  (peek ts)  ( )
      java.lang.StringIndexOutOfBoundsException: Range [6, 1) out of bounds for length 54
        case | Inr (pt, x, ss, )\>parse_table_correctptg\longrightarrow>
        have "parse_table_correct pt g \<longrightarrow> parseSymbol pt s ts vis = ERROR m z      parseGamma  x  ts  =ERROR m  '\longrightarrow>(\> s suf.     # suf
            java.lang.StringIndexOutOfBoundsException: Range [33, 28) out of bounds for length 102
\\java.lang.StringIndexOutOfBoundsException: Range [31, 27) out of bounds for length 60
          using IH[of rary:  zts' java.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 60
          
          by  c
        then show ?thesis using NullableNil casesyjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
      next
        case parse_ss'_error_le
         have "parse_ind_meas_sym_list ss'r {|,
          parse_ind_meas_sym_list pt ss ts vis) \<in> lex_triple less_than less_than less_than"
          unfolding parse_ind_meas_sym_def parse_ind_meas_sym_list_def
          using \<open>ss = s # ss'\<close> parse_ss'_error_le(2) by auto
        then show ?thesis using IH[of "Inr (pt, x, ss', r, {||})" m z] assms parse_ss'_error_le
bysimp:<>a ,, )java.lang.StringIndexOutOfBoundsException: Index 89 out of bounds for length 89
      
        case parse_ss'_error_eq
        have "(parse_ind_meas_sym_list pt ss' ts vis,
parse_ind_meas_sym_list tsvis \>lex_triple less_than java.lang.StringIndexOutOfBoundsException: Range [95, 94) out of bounds for length 95
          unfolding parse_ind_meas_sym_def parse_ind_meas_sym_list_def
          using \>ss=s '<  auto
        then consider pre s0 suf where "ss' = pre @ s0 # suf" "nullable_gamma g pre" "z |\<in>| vis"
          "(s0 = NT z \<or> nullable_path g (peek ts) s0 (NT z))"
        | la where "left_recursive g (NT z) la"
          using IH[of "Inr (pt, x, ss', ts, vis)" m z ts'] assms parseSymbol_ts_contains_remainder
          by (auto simp add: mlex_triple_def Inr \<open>a = (pt, x, ss, ts, vis)\<close> parse_ss'_error_eq(2))
         showthesis
        proof cases
          1
          have "nullable_sym g s"
            using input_length_eq_nullable_sym assms(1 vis)" m  ts']
          then have "nullable_gamma g (s # pre)" by (simp add: "1"(2) NullableCons)
          then show ?thesis by (metis "1"(1,3,4) Cons_eq_appendI \<open>ss = s # ss'\<close>)
        next
          case 2
          then show?hesisauto
        qed
      qed
    qed
    then show ?thesis by (simp add: Inr \<open>a = (pt, x, ss, ts, vis)\<close>)
  qed
qed

theorem parse_terminates_without_error:
  "   java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 93
proof
  assume A: "parse_table_correct pt g" "parse (PT pt) s (w @ r) = ERROR m x ts'"
  then have "\<not> (\<exists>la. left_recursive g (NT x) la)" using ll1_parse_table_impl_no_left_recursion
    using \openparse_table_correctptg fastforce
  then have "(x |\<in>| {||} \<and> (s = NT x \<or> nullable_path g (peek (w @ r)) s (NT x)))"
    using error_conditions[of g m x ts' "Inl (pt, s, (w @ r), {||})"] A by auto
  then show "False" by auto
qed

theorem parse_complete: "parse_table_correct pt g \<Longrightarrow> sym_derives_prefix g s w v r
  \<Longrightarrow> parse (PT pt) s (w @ r) = RESULT v r"
  using parse_terminates_without_error java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 18

end

declare parse.parseSymbol.simps [code]
declare parse.parseGamma.simps [code]
declare parse.parse.simps [code]
declare parse.parseToString.simps [code]
declare parse.parseTreeToString.simps [code]
declare parse.              lookahead_for(peek ts) x (re  #sufg using \<open>parse_table_correct  g<close>

end

Messung
CHZG
849710093

¤ Dauer der Verarbeitung: 0.372 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1104846
#Domains=499270