section‹An alternative definition for POSIX values by Okui \& Suzuki›
section‹Positions in Values›
fun
at :: "'a val ==> nat list ==> 'a val" where "at v [] = v"
| "at (Left v) (0#ps)= at v ps"
| "at (Right v) (Suc 0#ps)= at v ps"
| "at (Seq v1 v2) (0#ps)= at v1 ps"
| "at (Seq v1 v2) (Suc 0#ps)= at v2 ps"
| "at (Stars vs) (n#ps)= at (nth vs n) ps"
fun Pos :: "'a val ==> (nat list) set" where "Pos (Void) = {[]}"
| "Pos (Atm c) = {[]}"
| "Pos (Left v) = {[]} ∪ {0#ps | ps. ps ∈ Pos v}"
| "Pos (Right v) = {[]} ∪ {1#ps | ps. ps ∈ Pos v}"
| "Pos (Seq v1 v2) = {[]} ∪ {0#ps | ps. ps ∈ Pos v1} ∪ {1#ps | ps. ps ∈ Pos v2}"
| "Pos (Stars []) = {[]}"
| "Pos (Stars (v#vs)) = {[]} ∪ {0#ps | ps. ps ∈ Pos v} ∪ {Suc n#ps | n ps. n#ps ∈ Pos (Stars vs)}"
section‹The Posix Value is smaller than any other lexical value›
lemma Posix_PosOrd: assumes"s ∈ r → v1""v2 ∈ LV r s" shows"v1 :⊑val v2" using assms proof (induct arbitrary: v2 rule: Posix.induct) case (Posix_One v) have"v ∈ LV One []"by fact thenhave"v = Void" by (simp add: LV_simps) thenshow"Void :⊑val v" by (simp add: PosOrd_ex_eq_def) next case (Posix_Atom c v) have"v ∈ LV (Atom c) [c]"by fact thenhave"v = Atm c" by (simp add: LV_simps) thenshow"Atm c :⊑val v" by (simp add: PosOrd_ex_eq_def) next case (Posix_Plus1 s r1 v r2 v2) have as1: "s ∈ r1 → v"by fact have IH: "∧v2. v2 ∈ LV r1 s ==> v :⊑val v2"by fact have"v2 ∈ LV (Plus r1 r2) s"by fact thenhave"⊨ v2 : Plus r1 r2""flat v2 = s" by(auto simp add: LV_def prefix_list_def) then consider
(Left) v3 where"v2 = Left v3""⊨ v3 : r1""flat v3 = s"
| (Right) v3 where"v2 = Right v3""⊨ v3 : r2""flat v3 = s" by (auto elim: Prf.cases) thenshow"Left v :⊑val v2" proof(cases) case (Left v3) have"v3 ∈ LV r1 s"using Left(2,3) by (auto simp add: LV_def prefix_list_def) with IH have"v :⊑val v3"by simp moreover have"flat v3 = flat v"using as1 Left(3) by (simp add: Posix1(2)) ultimatelyhave"Left v :⊑val Left v3" by (simp add: PosOrd_ex_eq_def PosOrd_Left_eq) thenshow"Left v :⊑val v2"unfolding Left . next case (Right v3) have"flat v3 = flat v"using as1 Right(3) by (simp add: Posix1(2)) thenhave"Left v :⊑val Right v3" unfolding PosOrd_ex_eq_def by (simp add: PosOrd_Left_Right) thenshow"Left v :⊑val v2"unfolding Right . qed next case (Posix_Plus2 s r2 v r1 v2) have as1: "s ∈ r2 → v"by fact have as2: "s ∉ lang r1"by fact have IH: "∧v2. v2 ∈ LV r2 s ==> v :⊑val v2"by fact have"v2 ∈ LV (Plus r1 r2) s"by fact thenhave"⊨ v2 : Plus r1 r2""flat v2 = s" by(auto simp add: LV_def prefix_list_def) then consider
(Left) v3 where"v2 = Left v3""⊨ v3 : r1""flat v3 = s"
| (Right) v3 where"v2 = Right v3""⊨ v3 : r2""flat v3 = s" by (auto elim: Prf.cases) thenshow"Right v :⊑val v2" proof (cases) case (Right v3) have"v3 ∈ LV r2 s"using Right(2,3) by (auto simp add: LV_def prefix_list_def) with IH have"v :⊑val v3"by simp moreover have"flat v3 = flat v"using as1 Right(3) by (simp add: Posix1(2)) ultimatelyhave"Right v :⊑val Right v3" by (auto simp add: PosOrd_ex_eq_def PosOrd_RightI) thenshow"Right v :⊑val v2"unfolding Right . next case (Left v3) have"v3 ∈ LV r1 s"using Left(2,3) as2 by (auto simp add: LV_def prefix_list_def) thenhave"flat v3 = flat v ∧⊨ v3 : r1"using as1 Left(3) by (simp add: Posix1(2) LV_def) thenhave"False"using as1 as2 Left by (auto simp add: Posix1(2) L_flat_Prf1) thenshow"Right v :⊑val v2"by simp qed next case (Posix_Times s1 r1 v1 s2 r2 v2 v3) have"s1 ∈ r1 → v1""s2 ∈ r2 → v2"by fact+ thenhave as1: "s1 = flat v1""s2 = flat v2"by (simp_all add: Posix1(2)) have IH1: "∧v3. v3 ∈ LV r1 s1 ==> v1 :⊑val v3"by fact have IH2: "∧v3. v3 ∈ LV r2 s2 ==> v2 :⊑val v3"by fact have cond: "¬ (∃s3 s4. s3≠ [] ∧ s3 @ s4 = s2 ∧ s1 @ s3∈ lang r1 ∧ s4∈ lang r2)"by fact have"v3 ∈ LV (Times r1 r2) (s1 @ s2)"by fact thenobtain v3a v3b where eqs: "v3 = Seq v3a v3b""⊨ v3a : r1""⊨ v3b : r2" "flat v3a @ flat v3b = s1 @ s2" by (force simp add: prefix_list_def LV_def elim: Prf.cases) with cond have"flat v3a ⊑pre s1"unfolding prefix_list_def by (smt (verit) L_flat_Prf1 append_eq_append_conv2 append_self_conv) thenhave"flat v3a ⊏spre s1 ∨ (flat v3a = s1 ∧ flat v3b = s2)"using eqs by (simp add: sprefix_list_def append_eq_conv_conj) thenhave q2: "v1 :⊏val v3a ∨ (flat v3a = s1 ∧ flat v3b = s2)" using PosOrd_spreI as1(1) eqs by blast thenhave"v1 :⊏val v3a ∨ (v3a ∈ LV r1 s1 ∧ v3b ∈ LV r2 s2)"using eqs(2,3) by (auto simp add: LV_def) thenhave"v1 :⊏val v3a ∨ (v1 :⊑val v3a ∧ v2 :⊑val v3b)"using IH1 IH2 by blast thenhave"Seq v1 v2 :⊑val Seq v3a v3b"using eqs q2 as1 unfolding PosOrd_ex_eq_def by (auto simp add: PosOrd_SeqI1 PosOrd_Seq_eq) thenshow"Seq v1 v2 :⊑val v3"unfolding eqs by blast next case (Posix_Star1 s1 r v s2 vs v3) have"s1 ∈ r → v""s2 ∈ Star r → Stars vs"by fact+ thenhave as1: "s1 = flat v""s2 = flat (Stars vs)"by (auto dest: Posix1(2)) have IH1: "∧v3. v3 ∈ LV r s1 ==> v :⊑val v3"by fact have IH2: "∧v3. v3 ∈ LV (Star r) s2 ==> Stars vs :⊑val v3"by fact have cond: "¬ (∃s3 s4. s3≠ [] ∧ s3 @ s4 = s2 ∧ s1 @ s3∈ lang r ∧ s4∈ lang (Star r))"by fact have cond2: "flat v ≠ []"by fact have"v3 ∈ LV (Star r) (s1 @ s2)"by fact then consider
(NonEmpty) v3a vs3 where"v3 = Stars (v3a # vs3)" "⊨ v3a : r""⊨ Stars vs3 : Star r" "flat (Stars (v3a # vs3)) = s1 @ s2"
| (Empty) "v3 = Stars []" unfolding LV_def apply(auto) apply(erule Prf_elims) by (metis NonEmpty Prf.intros(6) list.set_intros(1) list.set_intros(2) neq_Nil_conv) thenshow"Stars (v # vs) :⊑val v3" proof (cases) case (NonEmpty v3a vs3) have"flat (Stars (v3a # vs3)) = s1 @ s2"using NonEmpty(4) . with cond have"flat v3a ⊑pre s1"using NonEmpty(2,3) unfolding prefix_list_def by (smt (verit) Prf_flat_lang append.right_neutral append_eq_append_conv2
flat.simps(7)) thenhave"flat v3a ⊏spre s1 ∨ (flat v3a = s1 ∧ flat (Stars vs3) = s2)"using NonEmpty(4) by (simp add: sprefix_list_def append_eq_conv_conj) thenhave q2: "v :⊏val v3a ∨ (flat v3a = s1 ∧ flat (Stars vs3) = s2)" using PosOrd_spreI as1(1) NonEmpty(4) by blast thenhave"v :⊏val v3a ∨ (v3a ∈ LV r s1 ∧ Stars vs3 ∈ LV (Star r) s2)" using NonEmpty(2,3) by (auto simp add: LV_def) thenhave"v :⊏val v3a ∨ (v :⊑val v3a ∧ Stars vs :⊑val Stars vs3)"using IH1 IH2 by blast thenhave"v :⊏val v3a ∨ (v = v3a ∧ Stars vs :⊑val Stars vs3)" unfolding PosOrd_ex_eq_def by auto thenhave"Stars (v # vs) :⊑val Stars (v3a # vs3)"using NonEmpty(4) q2 as1 unfolding PosOrd_ex_eq_def using PosOrd_StarsI PosOrd_StarsI2 by (metis flat.simps(7) flat_Stars val.inject(5)) thenshow"Stars (v # vs) :⊑val v3"unfolding NonEmpty by blast next case Empty have"v3 = Stars []"by fact thenshow"Stars (v # vs) :⊑val v3" unfolding PosOrd_ex_eq_def using cond2 by (simp add: PosOrd_shorterI) qed next case (Posix_Star2 r v2) have"v2 ∈ LV (Star r) []"by fact thenhave"v2 = Stars []" unfolding LV_def by (auto elim: Prf.cases) thenshow"Stars [] :⊑val v2" by (simp add: PosOrd_ex_eq_def) qed
lemma Posix_PosOrd_reverse: assumes"s ∈ r → v1" shows"¬(∃v2 ∈ LV r s. v2 :⊏val v1)" using assms by (metis Posix_PosOrd less_irrefl PosOrd_def
PosOrd_ex_eq_def PosOrd_ex_def PosOrd_trans)
lemma PosOrd_Posix: assumes"v1 ∈ LV r s""∀v2∈ LV r s. ¬ v2 :⊏val v1" shows"s ∈ r → v1" proof - have"s ∈ lang r"using assms(1) unfolding LV_def using L_flat_Prf1 by blast thenobtain vposix where vp: "s ∈ r → vposix" using lexer_correct_Some by blast with assms(1) have"vposix :⊑val v1"by (simp add: Posix_PosOrd) thenhave"vposix = v1 ∨ vposix :⊏val v1"unfolding PosOrd_ex_eq2 by auto moreover
{ assume"vposix :⊏val v1" moreover have"vposix ∈ LV r s"using vp using Posix_LV by blast ultimatelyhave"False"using assms(2) by blast
} ultimatelyshow"s ∈ r → v1"using vp by blast qed
lemma Least_existence: assumes"LV r s ≠ {}" shows" ∃vmin ∈ LV r s. ∀v ∈ LV r s. vmin :⊑val v" proof - from assms obtain vposix where"s ∈ r → vposix" unfolding LV_def using L_flat_Prf1 lexer_correct_Some by blast thenhave"∀v ∈ LV r s. vposix :⊑val v" by (simp add: Posix_PosOrd) thenshow"∃vmin ∈ LV r s. ∀v ∈ LV r s. vmin :⊑val v" using Posix_LV ‹s ∈ r → vposix›by blast qed
lemma Least_existence1: assumes"LV r s ≠ {}" shows" ∃! vmin∈ LV r s. ∀v ∈ LV r s. vmin :⊑val v" using Least_existence[OF assms] assms using PosOrdeq_antisym by blast
lemma Least_existence2: assumes"LV r s ≠ {}" shows" ∃!vmin ∈ LV r s. lexer r s = Some vmin ∧ (∀v ∈ LV r s. vmin :⊑val v)" using Least_existence[OF assms] assms using PosOrdeq_antisym using PosOrd_Posix PosOrd_ex_eq2 lexer_correctness(1) by (metis (mono_tags, lifting))
lemma Least_existence1_pre: assumes"LV r s ≠ {}" shows" ∃!vmin ∈ LV r s. ∀v ∈ (LV r s ∪ {v'. flat v' ⊏spre s}). vmin :⊑val v" using Least_existence[OF assms] assms apply - apply(erule bexE) apply(rule_tac a="vmin"in ex1I) apply(auto)[1] apply (metis PosOrd_Posix PosOrd_ex_eq2 PosOrd_spreI PosOrdeq_antisym Posix1(2)) apply(auto)[1] apply(simp add: PosOrdeq_antisym) done
lemma PosOrd_wf: shows"wf {(v1, v2). v1 :⊏val v2 ∧ v1 ∈ LV r s ∧ v2 ∈ LV r s}" proof - have"finite {(v1, v2). v1 ∈ LV r s ∧ v2 ∈ LV r s}" by (simp add: LV_finite) moreover have"{(v1, v2). v1 :⊏val v2 ∧ v1 ∈ LV r s ∧ v2 ∈ LV r s} ⊆ {(v1, v2). v1 ∈ LV r s ∧ v2 ∈ LV r s}" by auto ultimatelyhave"finite {(v1, v2). v1 :⊏val v2 ∧ v1 ∈ LV r s ∧ v2 ∈ LV r s}" using finite_subset by blast moreover have"acyclicP (λv1 v2. v1 :⊏val v2 ∧ v1 ∈ LV r s ∧ v2 ∈ LV r s)" unfolding acyclic_def by (smt (verit, ccfv_threshold) PosOrd_irrefl PosOrd_trans tranclp_trans_induct tranclp_unfold) ultimatelyshow"wf {(v1, v2). v1 :⊏val v2 ∧ v1 ∈ LV r s ∧ v2 ∈ LV r s}" using finite_acyclic_wf by blast qed
unused_thms
end
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet am 2026-06-10)
¤
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.